updatertest

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package updatertest serves fake GitHub releases of xibodev/compa, shaped like the ones the release workflow publishes, for tests of the updater and of the endpoints built on it.

Index

Constants

View Source
const NoDigest = "none"

NoDigest as an Asset's Digest makes the fake API report no digest for it.

Variables

This section is empty.

Functions

func Archive

func Archive(t testing.TB, goos string, files map[string]string) []byte

Archive packs files the way the release workflow does: a zip for Windows, a tar.gz otherwise, every file at the root.

func ArchiveName

func ArchiveName(tag, goos, goarch string) string

ArchiveName is the asset name a release uses for goos/goarch.

func Programs

func Programs(goos, launcher, kernel string) map[string]string

Programs is the content of a release archive for goos: compa and compa-kernel (with ".exe" on Windows) plus LICENSE and NOTICE.

func SHA256

func SHA256(b []byte) string

SHA256 is the lowercase hex SHA-256 of b.

func Server

func Server(t testing.TB, releases ...Release) *httptest.Server

Server answers the GitHub releases API of xibodev/compa and serves the assets. The first release is the latest one. Point the updater's APIBaseURL at the returned server's URL.

Types

type Asset

type Asset struct {
	Name string
	Body []byte
	// Digest is what the API reports as the asset's digest: empty reports the
	// real SHA-256 of Body, NoDigest reports none, anything else is reported
	// verbatim.
	Digest string
}

Asset is one file attached to a fake release.

func Checksums

func Checksums(assets ...Asset) Asset

Checksums is a SHA256SUMS asset covering assets, in sha256sum's format.

type Release

type Release struct {
	Tag    string
	Assets []Asset
}

Release is one published release.

func Build

func Build(t testing.TB, tag, goos, goarch, launcher, kernel string) Release

Build is a complete release for goos/goarch: the archive holding the two programs with the given contents, and SHA256SUMS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL