Documentation
¶
Overview ¶
Package storagetesting is used for testing Storage implementations.
Index ¶
- func AssertConnectionInfoRoundTrips(ctx context.Context, t *testing.T, s storage.Storage)
- func AssertGetBlock(ctx context.Context, t *testing.T, s storage.Storage, block string, ...)
- func AssertGetBlockNotFound(ctx context.Context, t *testing.T, s storage.Storage, block string)
- func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s storage.Storage, block string, ...)
- func AssertListResults(ctx context.Context, t *testing.T, s storage.Storage, prefix string, ...)
- func NewMapStorage(data map[string][]byte, keyTime map[string]time.Time, timeNow func() time.Time) storage.Storage
- func VerifyStorage(ctx context.Context, t *testing.T, r storage.Storage)
- type Fault
- type FaultyStorage
- func (s *FaultyStorage) Close(ctx context.Context) error
- func (s *FaultyStorage) ConnectionInfo() storage.ConnectionInfo
- func (s *FaultyStorage) DeleteBlock(ctx context.Context, id string) error
- func (s *FaultyStorage) GetBlock(ctx context.Context, id string, offset, length int64) ([]byte, error)
- func (s *FaultyStorage) ListBlocks(ctx context.Context, prefix string, callback func(storage.BlockMetadata) error) error
- func (s *FaultyStorage) PutBlock(ctx context.Context, id string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertConnectionInfoRoundTrips ¶
AssertConnectionInfoRoundTrips verifies that the ConnectionInfo returned by a given storage can be used to create equivalent storage
func AssertGetBlock ¶
func AssertGetBlock(ctx context.Context, t *testing.T, s storage.Storage, block string, expected []byte)
AssertGetBlock asserts that the specified storage block has correct content.
func AssertGetBlockNotFound ¶
AssertGetBlockNotFound asserts that GetBlock() for specified storage block returns ErrBlockNotFound.
func AssertInvalidOffsetLength ¶
func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s storage.Storage, block string, offset, length int64)
AssertInvalidOffsetLength verifies that the given combination of (offset,length) fails on GetBlock()
func AssertListResults ¶
func AssertListResults(ctx context.Context, t *testing.T, s storage.Storage, prefix string, want ...string)
AssertListResults asserts that the list results with given prefix return the specified list of names in order.
Types ¶
type Fault ¶
type Fault struct { Repeat int // how many times to repeat this fault Sleep time.Duration // sleep before returning ErrCallback func() error WaitFor chan struct{} // waits until the given channel is closed before returning Err error // error to return (can be nil in combination with Sleep and WaitFor) }
Fault describes the behavior of a single fault.
type FaultyStorage ¶
type FaultyStorage struct { Base storage.Storage Faults map[string][]*Fault // contains filtered or unexported fields }
FaultyStorage implements fault injection for Storage.
func (*FaultyStorage) Close ¶
func (s *FaultyStorage) Close(ctx context.Context) error
Close implements storage.Storage
func (*FaultyStorage) ConnectionInfo ¶
func (s *FaultyStorage) ConnectionInfo() storage.ConnectionInfo
ConnectionInfo implements storage.Storage
func (*FaultyStorage) DeleteBlock ¶
func (s *FaultyStorage) DeleteBlock(ctx context.Context, id string) error
DeleteBlock implements storage.Storage
func (*FaultyStorage) GetBlock ¶
func (s *FaultyStorage) GetBlock(ctx context.Context, id string, offset, length int64) ([]byte, error)
GetBlock implements storage.Storage
func (*FaultyStorage) ListBlocks ¶
func (s *FaultyStorage) ListBlocks(ctx context.Context, prefix string, callback func(storage.BlockMetadata) error) error
ListBlocks implements storage.Storage