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 ¶
- func RunStoreSuite(t *testing.T, newStore func(t *testing.T) artifact.Store)
- type Backend
- func (b *Backend) Create(_ context.Context, bucket, key string) (artifact.Writer, error)
- func (b *Backend) Creates() int64
- func (b *Backend) Delete(_ context.Context, ref artifact.Ref) error
- func (b *Backend) Deletes() int64
- func (b *Backend) Has(bucket, key string) bool
- func (b *Backend) Name() string
- func (b *Backend) Open(ctx context.Context, ref artifact.Ref) (io.ReadCloser, error)
- func (b *Backend) Opens() int64
- func (b *Backend) Put(bucket, key string, data []byte)
- func (b *Backend) Stat(_ context.Context, ref artifact.Ref) (artifact.ObjectInfo, error)
- func (b *Backend) Stats() int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunStoreSuite ¶
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.