Documentation
¶
Overview ¶
Package testutil provides global testing helper functions
Index ¶
- func ChecksumZarfYAMLContent(t *testing.T, pkg v1alpha1.ZarfPackage) string
- func FillValue(v reflect.Value, rng *rand.Rand)
- func NewRepo(t *testing.T, refStr string) *remote.Repository
- func PushBlob(ctx context.Context, t *testing.T, repo *remote.Repository, mediaType string, ...) ocispec.Descriptor
- func PushImage(ctx context.Context, t *testing.T, repoRef, tag string) string
- func PushIndex(ctx context.Context, t *testing.T, repo *remote.Repository, ...) ocispec.Descriptor
- func PushManifest(ctx context.Context, t *testing.T, repo *remote.Repository, ...) ocispec.Descriptor
- func PushMultiArchIndex(ctx context.Context, t *testing.T, repoRef, tag string, ...) string
- func PushNestedIndex(ctx context.Context, t *testing.T, repoRef, tag string, ...) string
- func PushSinglePlatformImage(ctx context.Context, t *testing.T, repo *remote.Repository, arch string) ocispec.Descriptor
- func PushSinglePlatformImageWithLayer(ctx context.Context, t *testing.T, repo *remote.Repository, arch string, ...) ocispec.Descriptor
- func RandomBytes(t *testing.T, n int) []byte
- func RequireNoBackslashInPackagePaths(t *testing.T, pkg v1alpha1.ZarfPackage)
- func SetupInMemoryRegistry(ctx context.Context, t *testing.T, port int) string
- func SetupInMemoryRegistryDynamic(ctx context.Context, t *testing.T) string
- func TestContext(t *testing.T) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChecksumZarfYAMLContent ¶ added in v0.75.1
func ChecksumZarfYAMLContent(t *testing.T, pkg v1alpha1.ZarfPackage) string
ChecksumZarfYAMLContent returns sha256(marshal(pkg)) with pkg.Build zeroed. Build carries intrinsically non-reproducible values (timestamp, user, hostname, CLI version) so it is excluded; the result pins everything else and must be stable across build hosts.
func FillValue ¶ added in v0.83.0
FillValue recursively populates v with random, non-zero values for round-trip fuzz tests. Struct fields that cannot be set via reflection (unexported) are left zero. Pointers are left nil roughly half the time so both the set and unset states are exercised.
func NewRepo ¶ added in v0.76.0
func NewRepo(t *testing.T, refStr string) *remote.Repository
NewRepo returns a plaintext-HTTP oras-go Repository suitable for pushing fixtures into an in-memory registry during tests.
func PushBlob ¶ added in v0.76.0
func PushBlob(ctx context.Context, t *testing.T, repo *remote.Repository, mediaType string, data []byte) ocispec.Descriptor
PushBlob pushes raw bytes with the given media type and returns the resulting descriptor.
func PushImage ¶ added in v0.76.0
PushImage pushes a single-manifest image and tags it; returns the manifest digest.
func PushIndex ¶ added in v0.76.0
func PushIndex(ctx context.Context, t *testing.T, repo *remote.Repository, children []ocispec.Descriptor) ocispec.Descriptor
PushIndex builds and pushes an OCI image index referencing the given child descriptors. Children may themselves be manifests or indexes; nested indexes are supported by the OCI spec.
func PushManifest ¶ added in v0.76.0
func PushManifest(ctx context.Context, t *testing.T, repo *remote.Repository, config ocispec.Descriptor, layers []ocispec.Descriptor) ocispec.Descriptor
PushManifest constructs an image manifest pointing at the given config and layers, pushes it, and returns its descriptor.
func PushMultiArchIndex ¶ added in v0.76.0
func PushMultiArchIndex(ctx context.Context, t *testing.T, repoRef, tag string, platforms []ocispec.Platform) string
PushMultiArchIndex pushes a flat multi-arch OCI image index with one single-platform manifest per entry in platforms. Returns the index digest.
func PushNestedIndex ¶ added in v0.76.0
func PushNestedIndex(ctx context.Context, t *testing.T, repoRef, tag string, platforms []ocispec.Platform) string
PushNestedIndex pushes an OCI image index whose only child is itself an image index containing one single-platform manifest per entry in platforms. Returns the outer index digest.
func PushSinglePlatformImage ¶ added in v0.76.0
func PushSinglePlatformImage(ctx context.Context, t *testing.T, repo *remote.Repository, arch string) ocispec.Descriptor
PushSinglePlatformImage creates a config blob, a random layer, and a manifest that references both. The config embeds arch so distinct architectures produce distinct config blobs.
func PushSinglePlatformImageWithLayer ¶ added in v0.77.0
func PushSinglePlatformImageWithLayer(ctx context.Context, t *testing.T, repo *remote.Repository, arch string, layer ocispec.Descriptor) ocispec.Descriptor
PushSinglePlatformImageWithLayer pushes a single platform image with a defined layer
func RandomBytes ¶ added in v0.76.0
RandomBytes returns n cryptographically random bytes; used as blob content that hashes differently on every test run.
func RequireNoBackslashInPackagePaths ¶ added in v0.75.1
func RequireNoBackslashInPackagePaths(t *testing.T, pkg v1alpha1.ZarfPackage)
RequireNoBackslashInPackagePaths asserts every path field serialized into a built zarf.yaml uses forward-slash separators, so artifacts are byte-identical across build hosts.
func SetupInMemoryRegistry ¶ added in v0.38.2
SetupInMemoryRegistry sets up an in-memory registry on localhost and returns the address.
func SetupInMemoryRegistryDynamic ¶ added in v0.76.0
SetupInMemoryRegistryDynamic starts an in-memory registry on an auto-allocated port.
Types ¶
This section is empty.