artifacttest

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package artifacttest provides a shared conformance suite and test doubles for artifact storage.

Every artifact.Store implementation runs RunStoreSuite so all five backends are held to one contract. The suite's most important case is SweepNeverTouchesDurable: no sweep path, under any input, may mark a durable artifact.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStoreSuite

func RunStoreSuite(t *testing.T, newStore func(t *testing.T) artifact.Store)

RunStoreSuite exercises the artifact.Store contract. newStore must return a fresh, empty store on every call.

newStore receives the subtest's *testing.T, not the parent's. Backends that stand up a container or open a database per store must register teardown on that T so it runs when the subtest ends; closing over the parent T instead would hold every subtest's resources open until the whole suite finished, and would turn a setup t.Fatalf into a FailNow on a parent test.

Types

type Backend

type Backend struct {
	// DelayOpen makes Open sleep before returning, which is what lets a
	// single-flight test observe concurrent stagers colliding.
	DelayOpen time.Duration

	// DenyOpen makes Open fail with ErrPermissionDenied even when the
	// object is present. It exists so tests can cover a permanent failure
	// that is not a missing object: those two must be retried the same
	// way, which is to say not at all.
	DenyOpen bool
	// contains filtered or unexported fields
}

Backend is an in-memory artifact.Backend for tests. It counts calls so tests can assert on caching and single-flight behaviour.

func NewBackend

func NewBackend() *Backend

NewBackend returns an empty in-memory backend.

func (*Backend) Create

func (b *Backend) Create(_ context.Context, bucket, key string) (artifact.Writer, error)

Create begins writing a new object.

func (*Backend) Creates

func (b *Backend) Creates() int64

Creates returns how many times Create was called.

func (*Backend) Delete

func (b *Backend) Delete(_ context.Context, ref artifact.Ref) error

Delete removes an object. Deleting a missing object is not an error.

func (*Backend) Deletes

func (b *Backend) Deletes() int64

Deletes returns how many times Delete was called.

func (*Backend) Has

func (b *Backend) Has(bucket, key string) bool

Has reports whether an object exists.

func (*Backend) Name

func (b *Backend) Name() string

Name identifies this backend.

func (*Backend) Open

func (b *Backend) Open(ctx context.Context, ref artifact.Ref) (io.ReadCloser, error)

Open returns a reader over the object's bytes.

func (*Backend) Opens

func (b *Backend) Opens() int64

Opens returns how many times Open was called.

func (*Backend) Put

func (b *Backend) Put(bucket, key string, data []byte)

Put seeds an object directly, bypassing the Writer path.

func (*Backend) Stat

Stat reports the object's size.

func (*Backend) Stats

func (b *Backend) Stats() int64

Stats returns how many times Stat was called.

Jump to

Keyboard shortcuts

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