manifesttest

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package manifesttest stops tests from running against manifests that were never rendered.

The deploy/*/rendered directories are embedded with go:embed, but they are gitignored output of the make *-manifests targets. On a fresh clone each one holds only its .gitignore placeholder, so the embedded filesystem is empty, and tests that read it fail with unrelated errors, crash the test binary, or pass without checking anything. `make test` renders every set first; plain `go test`, `go test -run` and IDE test runners do not.

A package whose tests read rendered manifests calls Main from TestMain, so it fails once, before any test runs, and names the make targets to run.

Index

Constants

This section is empty.

Variables

View Source
var (
	Gantry = Set{
		Dir: "deploy/gantry/rendered", Target: "gantry-manifests", FS: gantrymanifests.Manifests,
	}
	Machina = Set{
		Dir: "deploy/machina/rendered", Target: "machina-manifests", FS: machinamanifests.Manifests,
	}
	Net = Set{
		Dir: "deploy/net/rendered", Target: "net-manifests", FS: netmanifests.Manifests,
	}
	TokenRefresher = Set{
		Dir: "deploy/token-refresher/rendered", Target: "token-refresher-manifests", FS: tokenrefreshermanifests.Manifests,
	}
	UnboundedOperator = Set{
		Dir: "deploy/unbounded-operator/rendered", Target: "unbounded-operator-manifests", FS: operatormanifests.Manifests,
	}
)

The rendered sets that tests read.

Functions

func Explain

func Explain(missing []Set) string

Explain says which sets are missing and the make command that renders them.

func Main

func Main(m *testing.M, sets ...Set) int

Main runs the package's tests only when every set is rendered. Otherwise it explains what to render and returns a failing exit code without running any test. Use it as the whole body of TestMain:

func TestMain(m *testing.M) {
	os.Exit(manifesttest.Main(m, manifesttest.Machina))
}

Types

type Set

type Set struct {
	// Dir is the directory's path in the repository.
	Dir string
	// Target is the make target that renders it.
	Target string
	// FS is the embedded directory.
	FS fs.FS
}

Set is one embedded directory of rendered manifests.

func Unrendered

func Unrendered(sets ...Set) ([]Set, error)

Unrendered returns the sets that hold no YAML manifests.

Jump to

Keyboard shortcuts

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