Documentation
¶
Overview ¶
Package storetest provides test doubles for store.ObjectStore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FaultHook ¶
FaultHook decides whether a FaultStore call should fail. key is the object key (List passes its prefix instead), and callNum is the 1-indexed count of calls to that method so far, including the current one. A nil return lets the call proceed to the wrapped store.
func AlwaysFail ¶
AlwaysFail returns a FaultHook that fails every call to that method.
type FaultStore ¶
type FaultStore struct {
ObjectStore
FailGet FaultHook
FailPut FaultHook
FailList FaultHook
// contains filtered or unexported fields
}
FaultStore wraps an ObjectStore and lets tests inject failures into Get, Put, or List independently of what the backend itself would do — simulating a network blip, a permission error, or a partial outage. Each hook is optional; a nil hook means that method always passes through.
FaultStore is safe for concurrent use.
type ObjectStore ¶
type ObjectStore interface {
Put(ctx context.Context, key string, data []byte) error
Get(ctx context.Context, key string) ([]byte, error)
Exists(ctx context.Context, key string) (bool, error)
Delete(ctx context.Context, key string) error
List(ctx context.Context, prefix string) ([]string, error)
Size(ctx context.Context, key string) (int64, error)
TotalSize(ctx context.Context) (int64, error)
Flush(ctx context.Context) error
}
ObjectStore mirrors the method set of store.ObjectStore. It is declared independently, rather than imported, so this package can also be used from pkg/store's own internal (package store) tests without an import cycle — any store.ObjectStore implementation satisfies this interface structurally.