testutil

package
v0.76.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package testutil provides global testing helper functions

Index

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 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

func PushImage(ctx context.Context, t *testing.T, repoRef, tag string) string

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 RandomBytes added in v0.76.0

func RandomBytes(t *testing.T, n int) []byte

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

func SetupInMemoryRegistry(ctx context.Context, t *testing.T, port int) string

SetupInMemoryRegistry sets up an in-memory registry on localhost and returns the address.

func SetupInMemoryRegistryDynamic added in v0.76.0

func SetupInMemoryRegistryDynamic(ctx context.Context, t *testing.T) string

SetupInMemoryRegistryDynamic starts an in-memory registry on an auto-allocated port.

func TestContext

func TestContext(t *testing.T) context.Context

TestContext takes a testing.T and returns a context that is attached to the test by t.Cleanup()

Types

This section is empty.

Jump to

Keyboard shortcuts

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