stiface

package
v0.0.0-...-1c9a4c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 5 Imported by: 52

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 ACLHandle

type ACLHandle interface {
	Delete(context.Context, storage.ACLEntity) error
	Set(context.Context, storage.ACLEntity, storage.ACLRole) error
	List(context.Context) ([]storage.ACLRule, error)
	// contains filtered or unexported methods
}

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 BucketIterator interface {
	SetPrefix(string)
	Next() (*storage.BucketAttrs, error)
	PageInfo() *iterator.PageInfo
	// contains filtered or unexported methods
}

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

func AdaptClient(c *storage.Client) Client

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 Copier

type Copier interface {
	ObjectAttrs() *storage.ObjectAttrs
	SetRewriteToken(string)
	SetProgressFunc(func(uint64, uint64))
	SetDestinationKMSKeyName(string)
	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 Reader

type Reader interface {
	io.ReadCloser
	Size() int64
	Remain() int64
	ContentType() string
	ContentEncoding() string
	CacheControl() string
	// 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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL