testutil

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildModelFromPath

func BuildModelFromPath(t *testing.T, path string) types.ModelArtifact

BuildModelFromPath constructs a model artifact from a file path and fails the test on error.

func NewStaticLayer added in v1.1.29

func NewStaticLayer(content []byte, mediaType oci.MediaType) oci.Layer

NewStaticLayer creates an in-memory layer for tests that do not need a backing file path.

func WithLayersError added in v1.1.29

func WithLayersError(base types.ModelArtifact, err error) types.ModelArtifact

WithLayersError returns a wrapper that fails when Layers is requested.

func WithRawConfigError added in v1.1.29

func WithRawConfigError(base types.ModelArtifact, err error) types.ModelArtifact

WithRawConfigError returns a wrapper that fails when RawConfigFile is requested.

Types

type Artifact added in v1.1.29

type Artifact struct {
	// contains filtered or unexported fields
}

Artifact is a generic, configurable OCI model artifact for testing. It accepts raw config bytes, a config media type, and an arbitrary set of layers, allowing tests to construct Docker model-spec, ModelPack, or any custom OCI artifact without re-implementing the ModelArtifact interface in every test file.

func NewArtifact added in v1.1.29

func NewArtifact(rawConfig []byte, configMediaType oci.MediaType, layers ...oci.Layer) *Artifact

NewArtifact creates a new generic test artifact with the given raw config bytes, config media type, and layers.

func NewDockerArtifact added in v1.1.29

func NewDockerArtifact(t *testing.T, cfg types.Config, layers ...LayerSpec) *Artifact

NewDockerArtifact creates a Docker-format test artifact with the default config media type.

func NewDockerArtifactWithConfigMediaType added in v1.1.29

func NewDockerArtifactWithConfigMediaType(
	t *testing.T,
	cfg types.Config,
	configMediaType oci.MediaType,
	layers ...LayerSpec,
) *Artifact

NewDockerArtifactWithConfigMediaType creates a Docker-format test artifact with the given config media type.

func NewGGUFArtifact added in v1.1.29

func NewGGUFArtifact(t *testing.T, modelPath string, extraLayers ...LayerSpec) *Artifact

NewGGUFArtifact creates a Docker-format GGUF test artifact.

func NewGGUFArtifactWithConfigMediaType added in v1.1.29

func NewGGUFArtifactWithConfigMediaType(
	t *testing.T,
	modelPath string,
	configMediaType oci.MediaType,
	extraLayers ...LayerSpec,
) *Artifact

NewGGUFArtifactWithConfigMediaType creates a GGUF test artifact with a custom Docker config media type.

func NewModelPackArtifact added in v1.1.29

func NewModelPackArtifact(t *testing.T, model modelpack.Model, layers ...LayerSpec) *Artifact

NewModelPackArtifact creates a ModelPack-format test artifact and populates ModelFS DiffIDs from the layers.

func NewSafetensorsArtifact added in v1.1.29

func NewSafetensorsArtifact(t *testing.T, modelPath string, extraLayers ...LayerSpec) *Artifact

NewSafetensorsArtifact creates a Docker-format safetensors test artifact.

func (*Artifact) Config added in v1.1.29

func (a *Artifact) Config() (types.ModelConfig, error)

Config implements types.ModelArtifact.

func (*Artifact) ConfigFile added in v1.1.29

func (a *Artifact) ConfigFile() (*oci.ConfigFile, error)

ConfigFile implements oci.Image. Model artifacts do not have a standard OCI config file.

func (*Artifact) ConfigName added in v1.1.29

func (a *Artifact) ConfigName() (oci.Hash, error)

ConfigName implements oci.Image.

func (*Artifact) Descriptor added in v1.1.29

func (a *Artifact) Descriptor() (types.Descriptor, error)

Descriptor implements types.ModelArtifact.

func (*Artifact) Digest added in v1.1.29

func (a *Artifact) Digest() (oci.Hash, error)

Digest implements oci.Image.

func (*Artifact) GetConfigMediaType added in v1.1.29

func (a *Artifact) GetConfigMediaType() oci.MediaType

GetConfigMediaType implements partial.WithConfigMediaType so that ManifestForLayers uses the correct config media type when building the OCI manifest.

func (*Artifact) ID added in v1.1.29

func (a *Artifact) ID() (string, error)

ID implements types.ModelArtifact.

func (*Artifact) LayerByDiffID added in v1.1.29

func (a *Artifact) LayerByDiffID(hash oci.Hash) (oci.Layer, error)

LayerByDiffID implements oci.Image.

func (*Artifact) LayerByDigest added in v1.1.29

func (a *Artifact) LayerByDigest(hash oci.Hash) (oci.Layer, error)

LayerByDigest implements oci.Image.

func (*Artifact) Layers added in v1.1.29

func (a *Artifact) Layers() ([]oci.Layer, error)

Layers implements oci.Image.

func (*Artifact) Manifest added in v1.1.29

func (a *Artifact) Manifest() (*oci.Manifest, error)

Manifest implements oci.Image.

func (*Artifact) MediaType added in v1.1.29

func (a *Artifact) MediaType() (oci.MediaType, error)

MediaType implements oci.Image.

func (*Artifact) RawConfigFile added in v1.1.29

func (a *Artifact) RawConfigFile() ([]byte, error)

RawConfigFile implements partial.WithRawConfigFile.

func (*Artifact) RawManifest added in v1.1.29

func (a *Artifact) RawManifest() ([]byte, error)

RawManifest implements oci.Image.

func (*Artifact) Size added in v1.1.29

func (a *Artifact) Size() (int64, error)

Size implements oci.Image.

type LayerSpec added in v1.1.29

type LayerSpec struct {
	Path         string
	RelativePath string
	MediaType    oci.MediaType
}

LayerSpec describes a test layer to create from a local file path.

func Layer added in v1.1.29

func Layer(path string, mediaType oci.MediaType) LayerSpec

Layer creates a layer spec with the file basename set as the unpacked relative path.

Jump to

Keyboard shortcuts

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