objectstoretest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package objectstoretest provides an in-memory objectstore.Store for tests that need to observe which external snapshots a flow created and released.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	// OnList, OnDelete and OnCopy, when set, run before the operation they name
	// and fail it if they return an error. Set them before the Fake is handed
	// to the code under test.
	OnList   func(bucket, prefix string) error
	OnDelete func(bucket, object string) error
	OnCopy   func(srcBucket, srcObject, dstBucket, dstObject string) error
	// contains filtered or unexported fields
}

Fake is an in-memory object store. It is safe for concurrent use, as the prefix helpers operate on several objects at once.

func New

func New() *Fake

New returns an empty Fake.

func (*Fake) Copy

func (f *Fake) Copy(_ context.Context, srcBucket, srcObject, dstBucket, dstObject string) error

func (*Fake) Delete

func (f *Fake) Delete(_ context.Context, bucket, object string) error

func (*Fake) List

func (f *Fake) List(_ context.Context, bucket, prefix string) ([]string, error)

func (*Fake) Objects

func (f *Fake) Objects() []string

Objects returns every object in the store as "bucket/object", sorted.

func (*Fake) Prefix

func (f *Fake) Prefix(t *testing.T, storagePrefix resources.StoragePrefix) []string

Prefix returns the names, relative to prefix, of every object below it. It is how a test asserts on a whole owner's subtree: that deleting one resource collected all of its objects, or left another's alone.

func (*Fake) Put

func (f *Fake) Put(bucket, object, content string)

Put writes one object, creating its bucket implicitly.

func (*Fake) PutSnapshot

func (f *Fake) PutSnapshot(t *testing.T, uri resources.SnapshotURI, names ...string)

PutSnapshot writes named objects into the external snapshot at uri, each holding its own name as content so a copy can be traced back to its source.

func (*Fake) Snapshot

func (f *Fake) Snapshot(t *testing.T, uri resources.SnapshotURI) []string

Snapshot returns the names, relative to uri, of the objects the external snapshot at uri is made of. An empty result means the snapshot is not there.

func (*Fake) WriteSnapshot

func (f *Fake) WriteSnapshot(snapshotURI string, names ...string) error

WriteSnapshot is PutSnapshot for callers outside a test body — a fake atelet serving a checkpoint has no *testing.T to fail on, and holds the destination as the unparsed URI it was sent.

Jump to

Keyboard shortcuts

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