Documentation ¶
Overview ¶
Package storage provides a mock rotate.StorageClient implementation
Index ¶
- type EnsureBucketExistsResponse
- type FakeObject
- type Mock
- func (s *Mock) Clone() *Mock
- func (s *Mock) EnsureBucketExists(_ context.Context, bucket string) error
- func (s *Mock) Exists(ctx context.Context, bucket, object string) (bool, error)
- func (s *Mock) IsNotExists(err error) bool
- func (s *Mock) Reader(_ context.Context, bucket, object string) (io.ReadCloser, error)
- func (s *Mock) Wipeout(_ context.Context, bucket string) error
- func (s *Mock) Writer(_ context.Context, bucket, object string) (io.WriteCloser, error)
- type ObjectReader
- type ObjectWriter
- type ReaderResponse
- type Responses
- type WriterResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnsureBucketExistsResponse ¶
type EnsureBucketExistsResponse struct {
Err error
}
EnsureBucketExistsResponse is the result of EnsureBucketExists for a given bucket.
type FakeObject ¶
type FakeObject struct {
Data []byte
}
FakeObject is a cell that can be used by readers and writers alike to manipulate an object's contents.
type Mock ¶
type Mock struct { BucketObjects map[string]map[string]*Responses EnsureResponses map[string]*EnsureBucketExistsResponse // contains filtered or unexported fields }
Mock implements the rotate.StorageClient interface to mock object contents.
func WithError ¶
WithError returns an initial Mock implementation that always returns the given error.
func WithInitialContents ¶
WithInitialContents returns an initial Mock implementation with objects with the given contents all in the same bucket.
func (*Mock) Clone ¶
Clone returns a new Mock with all objects containing the same contents in new cells.
func (*Mock) EnsureBucketExists ¶
EnsureBucketExists does nothing.
func (*Mock) IsNotExists ¶
IsNotExists returns whether an error returned from Mock represents the NotExists error.
type ObjectReader ¶
ObjectReader is an io.Reader that reads a FakeObject or errors, and returns an error on Close().
func (*ObjectReader) Close ¶
func (r *ObjectReader) Close() error
Close returns the canned CloseErr.
type ObjectWriter ¶
type ObjectWriter struct { M *Mock Bucket string Object string Content []byte WriteErr error CloseErr error }
ObjectWriter is an io.Writer that overwrites/creates a FakeObject with Content, or returns an error on Close().
func (*ObjectWriter) Close ¶
func (w *ObjectWriter) Close() error
Close commits Writer changes back to the Storage representation, or returns a canned error.
type ReaderResponse ¶
type ReaderResponse struct { ReaderMaker func() io.ReadCloser Err error }
ReaderResponse is the reader or error that Reader returns for a specific object.
type Responses ¶
type Responses struct { // If there is content, then it's stored here in Cell. Cell *FakeObject ReadResp *ReaderResponse WriteResp *WriterResponse }
Responses is a representation of the Reader and Writer responses at an object granularity.
type WriterResponse ¶
type WriterResponse struct { Writer io.WriteCloser Err error }
WriterResponse is the writer or error that Writer returns for a specific object.