ocitest

package
v0.0.0-...-eedc705 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ocitest provides some helper types for writing ociregistry-related tests. It's designed to be used alongside the qt package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasContent

func HasContent(r ociregistry.BlobReader, wantData []byte, wantMediaType string) qt.Checker

HasContent returns a checker that checks r matches the expected data and has the expected content type. If wantMediaType is empty, application/octet-stream will be expected.

func PushContent

PushContent pushes all the content in rc to r.

It returns a map mapping repository name to the descriptors describing the content that has actually been pushed.

Types

type PushedRepoContent

type PushedRepoContent struct {
	// Manifests holds an entry for each manifest identifier
	// with the descriptor for that manifest.
	Manifests map[string]ociregistry.Descriptor

	// ManifestData holds the actually pushed data for each manifest.
	ManifestData map[string][]byte

	// Blobs holds an entry for each blob identifier
	// with the descriptor for that manifest.
	Blobs map[string]ociregistry.Descriptor
}

PushedRepoContent mirrors RepoContent but, instead of describing content that is to be pushed, describes the content that has been pushed.

func PushRepoContent

func PushRepoContent(r ociregistry.Interface, repo string, repoc RepoContent) (PushedRepoContent, error)

PushRepoContent pushes the content for a single repository.

type Registry

type Registry struct {
	T *testing.T
	R ociregistry.Interface
}

func NewRegistry

func NewRegistry(t *testing.T, r ociregistry.Interface) Registry

NewRegistry returns a Registry instance that wraps r, providing convenience methods for pushing and checking content inside the given test instance.

When a Must* method fails, it will fail using t.

func (Registry) MustPushBlob

func (r Registry) MustPushBlob(repo string, data []byte) ociregistry.Descriptor

func (Registry) MustPushContent

func (r Registry) MustPushContent(rc RegistryContent) map[string]PushedRepoContent

PushContent pushes all the content in rc to r.

It returns a map mapping repository name to the descriptors describing the content that has actually been pushed.

func (Registry) MustPushManifest

func (r Registry) MustPushManifest(repo string, jsonObject any, tag string) ([]byte, ociregistry.Descriptor)

type RegistryContent

type RegistryContent map[string]RepoContent

RegistryContent specifies the contents of a registry: a map from repository name to the contents of that repository.

type Repo

type Repo struct {
	T    *testing.T
	Name string
	R    ociregistry.Interface
}

type RepoContent

type RepoContent struct {
	// Manifests maps from manifest identifier to the contents of the manifest.
	// TODO support manifest indexes too.
	Manifests map[string]ociregistry.Manifest

	// Blobs maps from blob identifer to the contents of the blob.
	Blobs map[string]string

	// Tags maps from tag name to manifest identifier.
	Tags map[string]string
}

RepoContent specifies the content of a repository. manifests and blobs are keyed by symbolic identifiers, not used inside the registry itself, but instead placeholders for the digest of the associated content.

Digest strings inside manifests that are not valid digests will be replaced by the calculated digest of the manifest or blob with that identifier; the size and media type fields will also be filled in.

Jump to

Keyboard shortcuts

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