Documentation ¶
Overview ¶
Package stiface provides a set of interfaces for the types in cloud.google.com/go/storage. These can be used to create mocks or other test doubles. The package also provides adapters to enable the types of the storage package to implement these interfaces.
We do not recommend using mocks for most testing. Please read https://testing.googleblog.com/2013/05/testing-on-toilet-dont-overuse-mocks.html.
Note: This package is in alpha. Some backwards-incompatible changes may occur.
You must embed these interfaces to implement them:
type ClientMock struct { stiface.Client ... }
This ensures that your implementations will not break when methods are added to the interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketHandle ¶
type BucketHandle interface { Create(context.Context, string, *storage.BucketAttrs) error Delete(context.Context) error DefaultObjectACL() ACLHandle Object(string) ObjectHandle Attrs(context.Context) (*storage.BucketAttrs, error) Update(context.Context, storage.BucketAttrsToUpdate) (*storage.BucketAttrs, error) If(storage.BucketConditions) BucketHandle Objects(context.Context, *storage.Query) ObjectIterator ACL() ACLHandle IAM() *iam.Handle UserProject(projectID string) BucketHandle Notifications(context.Context) (map[string]*storage.Notification, error) AddNotification(context.Context, *storage.Notification) (*storage.Notification, error) DeleteNotification(context.Context, string) error LockRetentionPolicy(context.Context) error // contains filtered or unexported methods }
type BucketIterator ¶
type Client ¶
type Client interface { Bucket(name string) BucketHandle Buckets(ctx context.Context, projectID string) BucketIterator Close() error // contains filtered or unexported methods }
func AdaptClient ¶
AdaptClient adapts a storage.Client so that it satisfies the Client interface.
type Composer ¶
type Composer interface { ObjectAttrs() *storage.ObjectAttrs Run(context.Context) (*storage.ObjectAttrs, error) // contains filtered or unexported methods }
type ObjectHandle ¶
type ObjectHandle interface { ACL() ACLHandle Generation(int64) ObjectHandle If(storage.Conditions) ObjectHandle Key([]byte) ObjectHandle ReadCompressed(bool) ObjectHandle Attrs(context.Context) (*storage.ObjectAttrs, error) Update(context.Context, storage.ObjectAttrsToUpdate) (*storage.ObjectAttrs, error) NewReader(context.Context) (Reader, error) NewRangeReader(context.Context, int64, int64) (Reader, error) NewWriter(context.Context) Writer Delete(context.Context) error CopierFrom(ObjectHandle) Copier ComposerFrom(...ObjectHandle) Composer // contains filtered or unexported methods }
type ObjectIterator ¶
type ObjectIterator interface { Next() (*storage.ObjectAttrs, error) PageInfo() *iterator.PageInfo // contains filtered or unexported methods }
type Writer ¶
type Writer interface { io.WriteCloser ObjectAttrs() *storage.ObjectAttrs SetChunkSize(int) SetProgressFunc(func(int64)) SetCRC32C(uint32) // Sets both CRC32C and SendCRC32C. CloseWithError(err error) error Attrs() *storage.ObjectAttrs // contains filtered or unexported methods }