mocks

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type S3Mock

type S3Mock struct {
	// GetObjectFunc mocks the GetObject method.
	GetObjectFunc func(ctx context.Context, bucketName string, objectName string, opts minio.GetObjectOptions) (*minio.Object, error)

	// ListBucketsFunc mocks the ListBuckets method.
	ListBucketsFunc func(ctx context.Context) ([]minio.BucketInfo, error)

	// ListObjectsFunc mocks the ListObjects method.
	ListObjectsFunc func(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo

	// MakeBucketFunc mocks the MakeBucket method.
	MakeBucketFunc func(ctx context.Context, bucketName string, opts minio.MakeBucketOptions) error

	// PresignedGetObjectFunc mocks the PresignedGetObject method.
	PresignedGetObjectFunc func(ctx context.Context, bucketName string, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)

	// PutObjectFunc mocks the PutObject method.
	PutObjectFunc func(ctx context.Context, bucketName string, objectName string, reader io.Reader, objectSize int64, opts minio.PutObjectOptions) (minio.UploadInfo, error)

	// RemoveBucketFunc mocks the RemoveBucket method.
	RemoveBucketFunc func(ctx context.Context, bucketName string) error

	// RemoveObjectFunc mocks the RemoveObject method.
	RemoveObjectFunc func(ctx context.Context, bucketName string, objectName string, opts minio.RemoveObjectOptions) error
	// contains filtered or unexported fields
}

S3Mock is a mock implementation of s3manager.S3.

func TestSomethingThatUsesS3(t *testing.T) {

	// make and configure a mocked s3manager.S3
	mockedS3 := &S3Mock{
		GetObjectFunc: func(ctx context.Context, bucketName string, objectName string, opts minio.GetObjectOptions) (*minio.Object, error) {
			panic("mock out the GetObject method")
		},
		ListBucketsFunc: func(ctx context.Context) ([]minio.BucketInfo, error) {
			panic("mock out the ListBuckets method")
		},
		ListObjectsFunc: func(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
			panic("mock out the ListObjects method")
		},
		MakeBucketFunc: func(ctx context.Context, bucketName string, opts minio.MakeBucketOptions) error {
			panic("mock out the MakeBucket method")
		},
		PresignedGetObjectFunc: func(ctx context.Context, bucketName string, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error) {
			panic("mock out the PresignedGetObject method")
		},
		PutObjectFunc: func(ctx context.Context, bucketName string, objectName string, reader io.Reader, objectSize int64, opts minio.PutObjectOptions) (minio.UploadInfo, error) {
			panic("mock out the PutObject method")
		},
		RemoveBucketFunc: func(ctx context.Context, bucketName string) error {
			panic("mock out the RemoveBucket method")
		},
		RemoveObjectFunc: func(ctx context.Context, bucketName string, objectName string, opts minio.RemoveObjectOptions) error {
			panic("mock out the RemoveObject method")
		},
	}

	// use mockedS3 in code that requires s3manager.S3
	// and then make assertions.

}

func (*S3Mock) GetObject

func (mock *S3Mock) GetObject(ctx context.Context, bucketName string, objectName string, opts minio.GetObjectOptions) (*minio.Object, error)

GetObject calls GetObjectFunc.

func (*S3Mock) GetObjectCalls

func (mock *S3Mock) GetObjectCalls() []struct {
	Ctx        context.Context
	BucketName string
	ObjectName string
	Opts       minio.GetObjectOptions
}

GetObjectCalls gets all the calls that were made to GetObject. Check the length with:

len(mockedS3.GetObjectCalls())

func (*S3Mock) ListBuckets

func (mock *S3Mock) ListBuckets(ctx context.Context) ([]minio.BucketInfo, error)

ListBuckets calls ListBucketsFunc.

func (*S3Mock) ListBucketsCalls

func (mock *S3Mock) ListBucketsCalls() []struct {
	Ctx context.Context
}

ListBucketsCalls gets all the calls that were made to ListBuckets. Check the length with:

len(mockedS3.ListBucketsCalls())

func (*S3Mock) ListObjects

func (mock *S3Mock) ListObjects(ctx context.Context, bucketName string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo

ListObjects calls ListObjectsFunc.

func (*S3Mock) ListObjectsCalls

func (mock *S3Mock) ListObjectsCalls() []struct {
	Ctx        context.Context
	BucketName string
	Opts       minio.ListObjectsOptions
}

ListObjectsCalls gets all the calls that were made to ListObjects. Check the length with:

len(mockedS3.ListObjectsCalls())

func (*S3Mock) MakeBucket

func (mock *S3Mock) MakeBucket(ctx context.Context, bucketName string, opts minio.MakeBucketOptions) error

MakeBucket calls MakeBucketFunc.

func (*S3Mock) MakeBucketCalls

func (mock *S3Mock) MakeBucketCalls() []struct {
	Ctx        context.Context
	BucketName string
	Opts       minio.MakeBucketOptions
}

MakeBucketCalls gets all the calls that were made to MakeBucket. Check the length with:

len(mockedS3.MakeBucketCalls())

func (*S3Mock) PresignedGetObject added in v0.5.0

func (mock *S3Mock) PresignedGetObject(ctx context.Context, bucketName string, objectName string, expiry time.Duration, reqParams url.Values) (*url.URL, error)

PresignedGetObject calls PresignedGetObjectFunc.

func (*S3Mock) PresignedGetObjectCalls added in v0.5.0

func (mock *S3Mock) PresignedGetObjectCalls() []struct {
	Ctx        context.Context
	BucketName string
	ObjectName string
	Expiry     time.Duration
	ReqParams  url.Values
}

PresignedGetObjectCalls gets all the calls that were made to PresignedGetObject. Check the length with:

len(mockedS3.PresignedGetObjectCalls())

func (*S3Mock) PutObject

func (mock *S3Mock) PutObject(ctx context.Context, bucketName string, objectName string, reader io.Reader, objectSize int64, opts minio.PutObjectOptions) (minio.UploadInfo, error)

PutObject calls PutObjectFunc.

func (*S3Mock) PutObjectCalls

func (mock *S3Mock) PutObjectCalls() []struct {
	Ctx        context.Context
	BucketName string
	ObjectName string
	Reader     io.Reader
	ObjectSize int64
	Opts       minio.PutObjectOptions
}

PutObjectCalls gets all the calls that were made to PutObject. Check the length with:

len(mockedS3.PutObjectCalls())

func (*S3Mock) RemoveBucket

func (mock *S3Mock) RemoveBucket(ctx context.Context, bucketName string) error

RemoveBucket calls RemoveBucketFunc.

func (*S3Mock) RemoveBucketCalls

func (mock *S3Mock) RemoveBucketCalls() []struct {
	Ctx        context.Context
	BucketName string
}

RemoveBucketCalls gets all the calls that were made to RemoveBucket. Check the length with:

len(mockedS3.RemoveBucketCalls())

func (*S3Mock) RemoveObject

func (mock *S3Mock) RemoveObject(ctx context.Context, bucketName string, objectName string, opts minio.RemoveObjectOptions) error

RemoveObject calls RemoveObjectFunc.

func (*S3Mock) RemoveObjectCalls

func (mock *S3Mock) RemoveObjectCalls() []struct {
	Ctx        context.Context
	BucketName string
	ObjectName string
	Opts       minio.RemoveObjectOptions
}

RemoveObjectCalls gets all the calls that were made to RemoveObject. Check the length with:

len(mockedS3.RemoveObjectCalls())

Jump to

Keyboard shortcuts

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