s3test

package
v0.0.0-...-36397d2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// IgnoreMissingSha256 suppresses checks for the
	// content checksum header.
	IgnoreMissingSha256 bool

	// Region holds the region of the bucket returned by
	// GetBucketLocationRequest.
	Region string

	// NumMaxRetries configures the maximum number of retries permitted
	// for operations involving this client.
	NumMaxRetries int

	s3iface.S3API
	// contains filtered or unexported fields
}

Client implements s3iface.S3API by using an AWS SDK client and overriding methods under test: HeadObject, ListObjectsV2, PutObjectRequest, CreateMultipartUploadRequest, UploadPartRequest, AbortMultipartUploadRequest, CompleteMultipartUploadRequest, GetObjectRequest, CopyObject, and DeleteObject. (These methods are sufficient to use with the S3 upload and download managers.)

File contents (and their checksums) are provided by the user.

func NewClient

func NewClient(t *testing.T, bucket string) *Client

NewClient constructs a new S3 client under test. The client reports errors to the given testing.T, and expects to receive requests for the given bucket.

func (*Client) AbortMultipartUploadRequest

func (c *Client) AbortMultipartUploadRequest(
	input *s3.AbortMultipartUploadInput) (req *request.Request, output *s3.AbortMultipartUploadOutput)

AbortMultipartUploadRequest stubs the corresponding s3iface.API method.

func (*Client) CompleteMultipartUploadRequest

func (c *Client) CompleteMultipartUploadRequest(
	input *s3.CompleteMultipartUploadInput) (req *request.Request, output *s3.CompleteMultipartUploadOutput)

CompleteMultipartUploadRequest stubs the corresponding s3iface.API method.

func (*Client) CompleteMultipartUploadWithContext

func (c *Client) CompleteMultipartUploadWithContext(
	ctx aws.Context, input *s3.CompleteMultipartUploadInput, opts ...request.Option) (
	*s3.CompleteMultipartUploadOutput, error)

CompleteMultipartUploadWithContext stubs the corresponding s3iface.API method.

func (*Client) CopyObject

func (c *Client) CopyObject(input *s3.CopyObjectInput) (*s3.CopyObjectOutput, error)

CopyObject implements S3-side object copying.

func (*Client) CopyObjectRequest

func (c *Client) CopyObjectRequest(
	input *s3.CopyObjectInput) (req *request.Request, output *s3.CopyObjectOutput)

CopyObjectRequest implements the Request model of server side object copying.

func (*Client) CreateMultipartUploadRequest

func (c *Client) CreateMultipartUploadRequest(
	input *s3.CreateMultipartUploadInput) (req *request.Request, output *s3.CreateMultipartUploadOutput)

CreateMultipartUploadRequest stubs the corresponding s3iface.API method.

func (*Client) CreateMultipartUploadWithContext

func (c *Client) CreateMultipartUploadWithContext(
	ctx aws.Context, input *s3.CreateMultipartUploadInput, opts ...request.Option) (
	*s3.CreateMultipartUploadOutput, error)

CreateMultipartUploadWithContext stubs the corresponding s3iface.API method.

func (*Client) DeleteObject

func (c *Client) DeleteObject(input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)

DeleteObject removes an object from the bucket.

func (*Client) DeleteObjectRequest

func (c *Client) DeleteObjectRequest(input *s3.DeleteObjectInput) (req *request.Request, out *s3.DeleteObjectOutput)

DeleteObjectRequest creates an RPC request for DeleteObject.

func (*Client) DeleteObjectWithContext

func (c *Client) DeleteObjectWithContext(ctx aws.Context, input *s3.DeleteObjectInput, opts ...request.Option) (*s3.DeleteObjectOutput, error)

DeleteObjectWithContext is the same as DeleteObject, but allows passing a context and options.

func (*Client) GetApiCount

func (c *Client) GetApiCount(api string) int

GetApiCount returns the number of invocations for the given API GetApiCount returns call. counts only for methods that are under GetApiCount returns test.

func (*Client) GetBucketLocationRequest

func (c *Client) GetBucketLocationRequest(input *s3.GetBucketLocationInput) (req *request.Request, output *s3.GetBucketLocationOutput)

GetBucketLocationRequest implements the bucket location (Client.Region) request.

func (*Client) GetFileContent

func (c *Client) GetFileContent(key string) testutil.ContentAt

GetFileContent returns ReaderAt defined by SetFileContent.

func (*Client) GetFileContentBytes

func (c *Client) GetFileContentBytes(key string) []byte

GetFileContentBytes returns the byte slice representation of the contents for key.

func (*Client) GetFileSha256

func (c *Client) GetFileSha256(key string) []byte

GetFileSha256 returns the sha256 defined by SetFileSha256.

func (*Client) GetObject

func (c *Client) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)

GetObject retrieves an object from the bucket.

func (*Client) GetObjectRequest

func (c *Client) GetObjectRequest(
	input *s3.GetObjectInput) (req *request.Request, output *s3.GetObjectOutput)

GetObjectRequest is used by by s3manager (aws-sdk < 1.8.0) to downoad files. GetObjectRequest is used by GetObjectWithContext by s3manager (aws-sdk >= 1.8.0) to downoad files.

func (*Client) GetObjectWithContext

func (c *Client) GetObjectWithContext(
	ctx aws.Context, input *s3.GetObjectInput, opts ...request.Option) (*s3.GetObjectOutput, error)

GetObjectWithContext is used within s3manager (aws-sdk >= 1.8.0) to downoad files, we leverage GetObjectRequest (from above) internally to do the work.

func (*Client) HasFileContent

func (c *Client) HasFileContent(key string) bool

HasFileContent returns whether the given key was set by SetFileContent.

func (*Client) HasPartialContent

func (c *Client) HasPartialContent(part int64) bool

HasPartialContent returns whether the given part was set by SetPartialContent.

func (*Client) HeadObject

func (c *Client) HeadObject(
	input *s3.HeadObjectInput) (output *s3.HeadObjectOutput, err error)

HeadObject is used in s3-loader to determine if an object in S3 and the local matching object are identical.

func (*Client) HeadObjectRequest

func (c *Client) HeadObjectRequest(input *s3.HeadObjectInput) (req *request.Request, out *s3.HeadObjectOutput)

HeadObjectRequest creates an RPC request for HeadObject.

func (*Client) HeadObjectWithContext

func (c *Client) HeadObjectWithContext(
	ctx aws.Context, input *s3.HeadObjectInput, opts ...request.Option) (output *s3.HeadObjectOutput, err error)

HeadObjectWithContext is the same as HeadObject, but allows passing a context and options.

func (*Client) ListObjectsV2

func (c *Client) ListObjectsV2(input *s3.ListObjectsV2Input) (*s3.ListObjectsV2Output, error)

ListObjectsV2 is used by DownloadDirTree to detemine all the files to download.

func (*Client) ListObjectsV2Request

func (c *Client) ListObjectsV2Request(
	input *s3.ListObjectsV2Input) (req *request.Request, output *s3.ListObjectsV2Output)

ListObjectsV2Request implements the request variant of ListObjectsV2.

func (*Client) ListObjectsV2WithContext

func (c *Client) ListObjectsV2WithContext(
	ctx aws.Context, input *s3.ListObjectsV2Input, opts ...request.Option) (*s3.ListObjectsV2Output, error)

ListObjectsV2WithContext is used by DownloadDirTree to detemine all the files to download.

func (*Client) MaxRetries

func (c *Client) MaxRetries() int

MaxRetries returns the maximum number of retries permitted for operations using this client.

func (*Client) PutObjectAcl

func (c *Client) PutObjectAcl(input *s3.PutObjectAclInput) (*s3.PutObjectAclOutput, error)

PutObjectAcl sets the ACL of an object already in the bucket.

func (*Client) PutObjectRequest

func (c *Client) PutObjectRequest(
	input *s3.PutObjectInput) (req *request.Request, output *s3.PutObjectOutput)

PutObjectRequest is used within s3manager to upload single part files.

func (*Client) SetFileContent

func (c *Client) SetFileContent(key string, content []byte)

SetFileContent defines the body for key.

TODO(saito) Call all Set* for a file atomically. Otherwise, the reader may observe, for example, contents for one version, and sha256 for another version

func (*Client) SetFileContentAt

func (c *Client) SetFileContentAt(key string, content testutil.ContentAt)

SetFileContentReader sets the underlying TestReader for content.

func (*Client) SetFileFromPartialContent

func (c *Client) SetFileFromPartialContent(key string)

SetFileFromPartialContent collects the content from partial and sets key in content with the result.

func (*Client) SetFileMetadata

func (c *Client) SetFileMetadata(key string, sha256 []byte, lastModified time.Time)

SetFileSha256 sets the sha256 for the given key.

func (*Client) SetPartialContent

func (c *Client) SetPartialContent(part int64, content []byte)

SetPartialContent defines the body for part.

func (*Client) UploadPartCopyRequest

func (c *Client) UploadPartCopyRequest(
	input *s3.UploadPartCopyInput) (req *request.Request, output *s3.UploadPartCopyOutput)

UploadPartCopyRequest stubs the corresponding s3iface.API method.

func (*Client) UploadPartCopyWithContext

func (c *Client) UploadPartCopyWithContext(
	ctx aws.Context, input *s3.UploadPartCopyInput, opts ...request.Option) (
	*s3.UploadPartCopyOutput, error)

UploadPartCopyWithContext stubs the corresponding s3iface.API method.

func (*Client) UploadPartRequest

func (c *Client) UploadPartRequest(
	input *s3.UploadPartInput) (req *request.Request, output *s3.UploadPartOutput)

UploadPartRequest stubs the corresponding s3iface.API method.

func (*Client) UploadPartWithContext

func (c *Client) UploadPartWithContext(
	ctx aws.Context, input *s3.UploadPartInput, opts ...request.Option) (
	*s3.UploadPartOutput, error)

UploadPartWithContext stubs the corresponding s3iface.API method.

Jump to

Keyboard shortcuts

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