Documentation ¶
Overview ¶
Package blobtesting is used for testing BLOB storage implementations.
Index ¶
- func AssertConnectionInfoRoundTrips(ctx context.Context, t *testing.T, s blob.Storage)
- func AssertGetBlob(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, ...)
- func AssertGetBlobNotFound(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID)
- func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, ...)
- func AssertListResults(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, ...)
- func NewMapStorage(data DataMap, keyTime map[blob.ID]time.Time, timeNow func() time.Time) blob.Storage
- func VerifyStorage(ctx context.Context, t *testing.T, r blob.Storage)
- type DataMap
- type Fault
- type FaultyStorage
- func (s *FaultyStorage) Close(ctx context.Context) error
- func (s *FaultyStorage) ConnectionInfo() blob.ConnectionInfo
- func (s *FaultyStorage) DeleteBlob(ctx context.Context, id blob.ID) error
- func (s *FaultyStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int64) ([]byte, error)
- func (s *FaultyStorage) ListBlobs(ctx context.Context, prefix blob.ID, callback func(blob.Metadata) error) error
- func (s *FaultyStorage) PutBlob(ctx context.Context, id blob.ID, 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 AssertGetBlob ¶
func AssertGetBlob(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, expected []byte)
AssertGetBlob asserts that the specified BLOB has correct content.
func AssertGetBlobNotFound ¶
AssertGetBlobNotFound asserts that GetBlob() for specified blobID returns ErrNotFound.
func AssertInvalidOffsetLength ¶
func AssertInvalidOffsetLength(ctx context.Context, t *testing.T, s blob.Storage, blobID blob.ID, offset, length int64)
AssertInvalidOffsetLength verifies that the given combination of (offset,length) fails on GetBlob()
func AssertListResults ¶
func AssertListResults(ctx context.Context, t *testing.T, s blob.Storage, prefix blob.ID, want ...blob.ID)
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 blob.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 blob.Storage
func (*FaultyStorage) ConnectionInfo ¶
func (s *FaultyStorage) ConnectionInfo() blob.ConnectionInfo
ConnectionInfo implements blob.Storage
func (*FaultyStorage) DeleteBlob ¶
DeleteBlob implements blob.Storage
func (*FaultyStorage) GetBlob ¶
func (s *FaultyStorage) GetBlob(ctx context.Context, id blob.ID, offset, length int64) ([]byte, error)
GetBlob implements blob.Storage