Documentation
¶
Overview ¶
Package ocitest provides an in-process OCI registry for tests, so tests never depend on real network access or a real container registry.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBrokenLayerRegistry ¶ added in v1.225.0
NewBrokenLayerRegistry starts an in-process OCI registry serving an image whose single layer declares the default tar+gzip media type but is not valid gzip data. The blob starts with the real gzip magic header (0x1f 0x8b) so go-containerregistry's compression sniffing selects the gzip decoder rather than treating the blob as an already-uncompressed tar (which would instead fail during tar parsing, not decompression); the remaining bytes are deliberately malformed so gzip.NewReader fails on the very first read, making the error deterministic and non-retryable.
func NewEmptyRegistry ¶ added in v1.225.0
NewEmptyRegistry starts an in-process OCI registry serving an image with no layers at all. It exercises the "manifest resolves but has zero layers" path (distinct from a network/auth failure), which real registries can legitimately serve for an empty or config-only image.
func NewRegistry ¶
NewRegistry starts an in-process OCI registry serving a single image built from files (archive path -> content, one uncompressed-tar layer). It returns the bare image reference "127.0.0.1:PORT/repoTag" (no "oci://" prefix, no scheme) -- callers building a component source.uri prefix it with "oci://" themselves. The go-containerregistry name.ParseReference function treats "127.0.0.1:PORT" addresses as plain HTTP automatically (see go-containerregistry's pkg/name/registry.go reLoopback), so no Insecure option is needed. The registry's httptest.Server is closed automatically via t.Cleanup.
func NewZipRegistry ¶
NewZipRegistry starts an in-process OCI registry serving a single image whose sole layer is a ZIP archive with media type "archive/zip" -- the format OpenTofu's native "install modules from OCI registries" feature uses (see https://opentofu.org, artifactType application/vnd.opentofu.modulepkg). Unlike NewRegistry's layer, this one is not gzip-wrapped: the blob is the raw zip bytes, matching what real OpenTofu module-package registries serve.
Types ¶
This section is empty.