Help us shape the future of Go! Take the 2026 Go Developer Survey

objectstore

package
v5.0.1 Latest Latest
Warning

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

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

Documentation

Overview

Package objectstore provides deterministic test doubles for AppTheory object-store code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Operation      Operation
	Ref            store.ObjectRef
	MaxBytes       int64
	ContentLength  int64
	ChecksumSHA256 string
	ExpiresIn      int64
	ContentType    string
	Metadata       map[string]string
	Payload        []byte
}

Call is one recorded FakeStore operation.

type FakeStore

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

FakeStore is an in-memory Store and UploadGranter for tests.

FakeStore records calls in order, injects per-operation failures, and copies all byte slices and metadata maps at its boundary.

func NewStore

func NewStore() *FakeStore

NewStore creates an empty FakeStore.

func (*FakeStore) Calls

func (s *FakeStore) Calls() []Call

Calls returns the recorded operations in call order.

func (*FakeStore) Delete

func (s *FakeStore) Delete(_ context.Context, input store.DeleteInput) error

Delete removes the referenced object. An unversioned ref removes all versions for the bucket/key.

func (*FakeStore) Get

func (s *FakeStore) Get(_ context.Context, input store.GetInput) (*store.GetOutput, error)

Get returns a bounded payload copy. MaxBytes must be positive.

func (*FakeStore) PresignPut

PresignPut mints a deterministic fake upload grant.

The URL encodes the signed constraints instead of hashing them, so tests can assert the exact grant without AWS. A real S3 store additionally signs the request host; the fake signs it too, which keeps the signed-header set identical between fake and real.

func (*FakeStore) Put

Put stores a payload copy and returns a version-aware reference.

func (*FakeStore) SetClock

func (s *FakeStore) SetClock(now func() time.Time)

SetClock replaces the deterministic clock used by PresignPut. Passing nil restores the fixed default instant, so upload grants stay reproducible across runs and runtimes.

func (*FakeStore) SetError

func (s *FakeStore) SetError(operation Operation, err error)

SetError injects err for subsequent calls to operation. Passing nil clears the injection.

type Operation

type Operation string

Operation names a Store operation recorded by FakeStore.

const (
	// OperationPut records a Store.Put call.
	OperationPut Operation = "Put"
	// OperationGet records a Store.Get call.
	OperationGet Operation = "Get"
	// OperationDelete records a Store.Delete call.
	OperationDelete Operation = "Delete"
	// OperationPresignPut records an UploadGranter.PresignPut call.
	OperationPresignPut Operation = "PresignPut"
)

Jump to

Keyboard shortcuts

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