Documentation
¶
Overview ¶
Package testutil is shared fixture scaffolding for tests across the repo — kept minimal so each test file stays self-describing.
Index ¶
- func DepRefs(ids ...manifest.NamedResource) []manifest.DependencyRef
- func MustYAML(t testing.TB, doc string) map[string]any
- func NewStoreWithStatuses(statuses map[manifest.NamedResource]store.Status) *store.Store
- func SelfSignedCA(t *testing.T) string
- func SelfSignedClientCert(t *testing.T) (cert, key string)
- func SelfSignedServerCert(t *testing.T) (cert, key string)
- func WaitForStatus(t *testing.T, st *store.Store, id manifest.NamedResource, want store.Status) store.StatusInfo
- func WriteFile(t testing.TB, root, rel, body string)
- func WriteFileAt(t testing.TB, path, body string)
- type MapLister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DepRefs ¶
func DepRefs(ids ...manifest.NamedResource) []manifest.DependencyRef
DepRefs wraps NamedResources as bare DependencyRefs (no ReadyExpr), the shape dependency-ordering tests use to express dependsOn edges.
func MustYAML ¶
MustYAML decodes a single YAML document literal into a generic map, failing the test on parse error or multi-document input.
func NewStoreWithStatuses ¶
NewStoreWithStatuses returns a fresh Store with each id pre-set to the given status (empty message), collapsing the store.New() + per-id UpdateStatus boilerplate common to dependency and render tests that need a pre-populated store.
func SelfSignedCA ¶
SelfSignedCA returns a PEM-encoded CA certificate.
func SelfSignedClientCert ¶
SelfSignedClientCert returns a PEM-encoded client cert and matching ECDSA private key — ExtKeyUsage is ClientAuth only.
func SelfSignedServerCert ¶
SelfSignedServerCert returns a PEM-encoded server+client cert and matching ECDSA private key — usable as both a TLS server cert and a CA bundle (IsCA=true).
func WaitForStatus ¶
func WaitForStatus(t *testing.T, st *store.Store, id manifest.NamedResource, want store.Status) store.StatusInfo
WaitForStatus polls st until id reaches want status or a 2-second deadline expires. It is the shared polling helper used by controller tests (helmrelease, kustomization, source) to avoid identical inline copies in each package.
func WriteFile ¶
WriteFile writes body to root/rel, creating any missing parent directories. Fails the test on any I/O error.
Accepts testing.TB so benchmarks (*testing.B) can share the same fixture helper as unit tests (*testing.T) — fixture building is part of the bench's setup phase, not the measured loop.
func WriteFileAt ¶
WriteFileAt writes body to path (absolute or cwd-relative), creating any missing parent directories. Companion to WriteFile for callers that already hold a full path rather than a root+rel split.
Types ¶
type MapLister ¶
type MapLister map[manifest.NamedResource]manifest.BaseManifest
MapLister is a test fixture that implements change.ObjectLister via a plain map. Used by controller tests that need a minimal ObjectLister (typically an empty one) to construct a change.Filter.
func EmptyLister ¶
func EmptyLister() MapLister
EmptyLister returns a MapLister with no entries — a minimal non-nil ObjectLister for tests that only need to construct a change.Filter.
func (MapLister) GetObject ¶
func (m MapLister) GetObject(id manifest.NamedResource) manifest.BaseManifest
GetObject returns the manifest stored under id, or nil if absent.
func (MapLister) ListObjects ¶
func (m MapLister) ListObjects(kind string) []manifest.BaseManifest
ListObjects returns all manifests whose kind matches the given string.