2018-04-24 22:35:21 +02:00
|
|
|
// Code generated by moq; DO NOT EDIT
|
|
|
|
// github.com/matryer/moq
|
|
|
|
|
2017-05-08 23:07:07 +02:00
|
|
|
package s3manager_test
|
|
|
|
|
|
|
|
import (
|
2018-04-24 22:35:21 +02:00
|
|
|
"github.com/minio/minio-go"
|
2017-05-08 23:07:07 +02:00
|
|
|
"io"
|
2018-04-24 22:35:21 +02:00
|
|
|
"sync"
|
|
|
|
)
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
var (
|
|
|
|
lockS3MockCopyObject sync.RWMutex
|
|
|
|
lockS3MockGetObject sync.RWMutex
|
|
|
|
lockS3MockListBuckets sync.RWMutex
|
|
|
|
lockS3MockListObjectsV2 sync.RWMutex
|
|
|
|
lockS3MockMakeBucket sync.RWMutex
|
|
|
|
lockS3MockPutObject sync.RWMutex
|
|
|
|
lockS3MockRemoveBucket sync.RWMutex
|
|
|
|
lockS3MockRemoveObject sync.RWMutex
|
2017-05-08 23:07:07 +02:00
|
|
|
)
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// S3Mock is a mock implementation of S3.
|
|
|
|
//
|
|
|
|
// func TestSomethingThatUsesS3(t *testing.T) {
|
|
|
|
//
|
|
|
|
// // make and configure a mocked S3
|
|
|
|
// mockedS3 := &S3Mock{
|
|
|
|
// CopyObjectFunc: func(in1 minio.DestinationInfo, in2 minio.SourceInfo) error {
|
|
|
|
// panic("TODO: mock out the CopyObject method")
|
|
|
|
// },
|
|
|
|
// GetObjectFunc: func(in1 string, in2 string, in3 minio.GetObjectOptions) (*minio.Object, error) {
|
|
|
|
// panic("TODO: mock out the GetObject method")
|
|
|
|
// },
|
|
|
|
// ListBucketsFunc: func() ([]minio.BucketInfo, error) {
|
|
|
|
// panic("TODO: mock out the ListBuckets method")
|
|
|
|
// },
|
|
|
|
// ListObjectsV2Func: func(in1 string, in2 string, in3 bool, in4 <-chan struct{}) <-chan minio.ObjectInfo {
|
|
|
|
// panic("TODO: mock out the ListObjectsV2 method")
|
|
|
|
// },
|
|
|
|
// MakeBucketFunc: func(in1 string, in2 string) error {
|
|
|
|
// panic("TODO: mock out the MakeBucket method")
|
|
|
|
// },
|
|
|
|
// PutObjectFunc: func(in1 string, in2 string, in3 io.Reader, in4 int64, in5 minio.PutObjectOptions) (int64, error) {
|
|
|
|
// panic("TODO: mock out the PutObject method")
|
|
|
|
// },
|
|
|
|
// RemoveBucketFunc: func(in1 string) error {
|
|
|
|
// panic("TODO: mock out the RemoveBucket method")
|
|
|
|
// },
|
|
|
|
// RemoveObjectFunc: func(in1 string, in2 string) error {
|
|
|
|
// panic("TODO: mock out the RemoveObject method")
|
|
|
|
// },
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// // TODO: use mockedS3 in code that requires S3
|
|
|
|
// // and then make assertions.
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
type S3Mock struct {
|
|
|
|
// CopyObjectFunc mocks the CopyObject method.
|
|
|
|
CopyObjectFunc func(in1 minio.DestinationInfo, in2 minio.SourceInfo) error
|
|
|
|
|
|
|
|
// GetObjectFunc mocks the GetObject method.
|
|
|
|
GetObjectFunc func(in1 string, in2 string, in3 minio.GetObjectOptions) (*minio.Object, error)
|
|
|
|
|
|
|
|
// ListBucketsFunc mocks the ListBuckets method.
|
|
|
|
ListBucketsFunc func() ([]minio.BucketInfo, error)
|
|
|
|
|
|
|
|
// ListObjectsV2Func mocks the ListObjectsV2 method.
|
|
|
|
ListObjectsV2Func func(in1 string, in2 string, in3 bool, in4 <-chan struct{}) <-chan minio.ObjectInfo
|
|
|
|
|
|
|
|
// MakeBucketFunc mocks the MakeBucket method.
|
|
|
|
MakeBucketFunc func(in1 string, in2 string) error
|
|
|
|
|
|
|
|
// PutObjectFunc mocks the PutObject method.
|
|
|
|
PutObjectFunc func(in1 string, in2 string, in3 io.Reader, in4 int64, in5 minio.PutObjectOptions) (int64, error)
|
|
|
|
|
|
|
|
// RemoveBucketFunc mocks the RemoveBucket method.
|
|
|
|
RemoveBucketFunc func(in1 string) error
|
|
|
|
|
|
|
|
// RemoveObjectFunc mocks the RemoveObject method.
|
|
|
|
RemoveObjectFunc func(in1 string, in2 string) error
|
|
|
|
|
|
|
|
// calls tracks calls to the methods.
|
|
|
|
calls struct {
|
|
|
|
// CopyObject holds details about calls to the CopyObject method.
|
|
|
|
CopyObject []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 minio.DestinationInfo
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 minio.SourceInfo
|
|
|
|
}
|
|
|
|
// GetObject holds details about calls to the GetObject method.
|
|
|
|
GetObject []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 string
|
|
|
|
// In3 is the in3 argument value.
|
|
|
|
In3 minio.GetObjectOptions
|
|
|
|
}
|
|
|
|
// ListBuckets holds details about calls to the ListBuckets method.
|
|
|
|
ListBuckets []struct {
|
|
|
|
}
|
|
|
|
// ListObjectsV2 holds details about calls to the ListObjectsV2 method.
|
|
|
|
ListObjectsV2 []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 string
|
|
|
|
// In3 is the in3 argument value.
|
|
|
|
In3 bool
|
|
|
|
// In4 is the in4 argument value.
|
|
|
|
In4 <-chan struct{}
|
|
|
|
}
|
|
|
|
// MakeBucket holds details about calls to the MakeBucket method.
|
|
|
|
MakeBucket []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 string
|
|
|
|
}
|
|
|
|
// PutObject holds details about calls to the PutObject method.
|
|
|
|
PutObject []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 string
|
|
|
|
// In3 is the in3 argument value.
|
|
|
|
In3 io.Reader
|
|
|
|
// In4 is the in4 argument value.
|
|
|
|
In4 int64
|
|
|
|
// In5 is the in5 argument value.
|
|
|
|
In5 minio.PutObjectOptions
|
|
|
|
}
|
|
|
|
// RemoveBucket holds details about calls to the RemoveBucket method.
|
|
|
|
RemoveBucket []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
}
|
|
|
|
// RemoveObject holds details about calls to the RemoveObject method.
|
|
|
|
RemoveObject []struct {
|
|
|
|
// In1 is the in1 argument value.
|
|
|
|
In1 string
|
|
|
|
// In2 is the in2 argument value.
|
|
|
|
In2 string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CopyObject calls CopyObjectFunc.
|
|
|
|
func (mock *S3Mock) CopyObject(in1 minio.DestinationInfo, in2 minio.SourceInfo) error {
|
|
|
|
if mock.CopyObjectFunc == nil {
|
|
|
|
panic("moq: S3Mock.CopyObjectFunc is nil but S3.CopyObject was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 minio.DestinationInfo
|
|
|
|
In2 minio.SourceInfo
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
|
|
|
}
|
|
|
|
lockS3MockCopyObject.Lock()
|
|
|
|
mock.calls.CopyObject = append(mock.calls.CopyObject, callInfo)
|
|
|
|
lockS3MockCopyObject.Unlock()
|
|
|
|
return mock.CopyObjectFunc(in1, in2)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CopyObjectCalls gets all the calls that were made to CopyObject.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.CopyObjectCalls())
|
|
|
|
func (mock *S3Mock) CopyObjectCalls() []struct {
|
|
|
|
In1 minio.DestinationInfo
|
|
|
|
In2 minio.SourceInfo
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 minio.DestinationInfo
|
|
|
|
In2 minio.SourceInfo
|
|
|
|
}
|
|
|
|
lockS3MockCopyObject.RLock()
|
|
|
|
calls = mock.calls.CopyObject
|
|
|
|
lockS3MockCopyObject.RUnlock()
|
|
|
|
return calls
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// GetObject calls GetObjectFunc.
|
|
|
|
func (mock *S3Mock) GetObject(in1 string, in2 string, in3 minio.GetObjectOptions) (*minio.Object, error) {
|
|
|
|
if mock.GetObjectFunc == nil {
|
|
|
|
panic("moq: S3Mock.GetObjectFunc is nil but S3.GetObject was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 minio.GetObjectOptions
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
|
|
|
In3: in3,
|
|
|
|
}
|
|
|
|
lockS3MockGetObject.Lock()
|
|
|
|
mock.calls.GetObject = append(mock.calls.GetObject, callInfo)
|
|
|
|
lockS3MockGetObject.Unlock()
|
|
|
|
return mock.GetObjectFunc(in1, in2, in3)
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// GetObjectCalls gets all the calls that were made to GetObject.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.GetObjectCalls())
|
|
|
|
func (mock *S3Mock) GetObjectCalls() []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 minio.GetObjectOptions
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 minio.GetObjectOptions
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
2018-04-24 22:35:21 +02:00
|
|
|
lockS3MockGetObject.RLock()
|
|
|
|
calls = mock.calls.GetObject
|
|
|
|
lockS3MockGetObject.RUnlock()
|
|
|
|
return calls
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// ListBuckets calls ListBucketsFunc.
|
|
|
|
func (mock *S3Mock) ListBuckets() ([]minio.BucketInfo, error) {
|
|
|
|
if mock.ListBucketsFunc == nil {
|
|
|
|
panic("moq: S3Mock.ListBucketsFunc is nil but S3.ListBuckets was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
}{}
|
|
|
|
lockS3MockListBuckets.Lock()
|
|
|
|
mock.calls.ListBuckets = append(mock.calls.ListBuckets, callInfo)
|
|
|
|
lockS3MockListBuckets.Unlock()
|
|
|
|
return mock.ListBucketsFunc()
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// ListBucketsCalls gets all the calls that were made to ListBuckets.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.ListBucketsCalls())
|
|
|
|
func (mock *S3Mock) ListBucketsCalls() []struct {
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
}
|
|
|
|
lockS3MockListBuckets.RLock()
|
|
|
|
calls = mock.calls.ListBuckets
|
|
|
|
lockS3MockListBuckets.RUnlock()
|
|
|
|
return calls
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// ListObjectsV2 calls ListObjectsV2Func.
|
|
|
|
func (mock *S3Mock) ListObjectsV2(in1 string, in2 string, in3 bool, in4 <-chan struct{}) <-chan minio.ObjectInfo {
|
|
|
|
if mock.ListObjectsV2Func == nil {
|
|
|
|
panic("moq: S3Mock.ListObjectsV2Func is nil but S3.ListObjectsV2 was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 bool
|
|
|
|
In4 <-chan struct{}
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
|
|
|
In3: in3,
|
|
|
|
In4: in4,
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
2018-04-24 22:35:21 +02:00
|
|
|
lockS3MockListObjectsV2.Lock()
|
|
|
|
mock.calls.ListObjectsV2 = append(mock.calls.ListObjectsV2, callInfo)
|
|
|
|
lockS3MockListObjectsV2.Unlock()
|
|
|
|
return mock.ListObjectsV2Func(in1, in2, in3, in4)
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// ListObjectsV2Calls gets all the calls that were made to ListObjectsV2.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.ListObjectsV2Calls())
|
|
|
|
func (mock *S3Mock) ListObjectsV2Calls() []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 bool
|
|
|
|
In4 <-chan struct{}
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 bool
|
|
|
|
In4 <-chan struct{}
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
2018-04-24 22:35:21 +02:00
|
|
|
lockS3MockListObjectsV2.RLock()
|
|
|
|
calls = mock.calls.ListObjectsV2
|
|
|
|
lockS3MockListObjectsV2.RUnlock()
|
|
|
|
return calls
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// MakeBucket calls MakeBucketFunc.
|
|
|
|
func (mock *S3Mock) MakeBucket(in1 string, in2 string) error {
|
|
|
|
if mock.MakeBucketFunc == nil {
|
|
|
|
panic("moq: S3Mock.MakeBucketFunc is nil but S3.MakeBucket was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
2018-04-24 22:35:21 +02:00
|
|
|
lockS3MockMakeBucket.Lock()
|
|
|
|
mock.calls.MakeBucket = append(mock.calls.MakeBucket, callInfo)
|
|
|
|
lockS3MockMakeBucket.Unlock()
|
|
|
|
return mock.MakeBucketFunc(in1, in2)
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// MakeBucketCalls gets all the calls that were made to MakeBucket.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.MakeBucketCalls())
|
|
|
|
func (mock *S3Mock) MakeBucketCalls() []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
}
|
|
|
|
lockS3MockMakeBucket.RLock()
|
|
|
|
calls = mock.calls.MakeBucket
|
|
|
|
lockS3MockMakeBucket.RUnlock()
|
|
|
|
return calls
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// PutObject calls PutObjectFunc.
|
|
|
|
func (mock *S3Mock) PutObject(in1 string, in2 string, in3 io.Reader, in4 int64, in5 minio.PutObjectOptions) (int64, error) {
|
|
|
|
if mock.PutObjectFunc == nil {
|
|
|
|
panic("moq: S3Mock.PutObjectFunc is nil but S3.PutObject was just called")
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
2018-04-24 22:35:21 +02:00
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 io.Reader
|
|
|
|
In4 int64
|
|
|
|
In5 minio.PutObjectOptions
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
|
|
|
In3: in3,
|
|
|
|
In4: in4,
|
|
|
|
In5: in5,
|
|
|
|
}
|
|
|
|
lockS3MockPutObject.Lock()
|
|
|
|
mock.calls.PutObject = append(mock.calls.PutObject, callInfo)
|
|
|
|
lockS3MockPutObject.Unlock()
|
|
|
|
return mock.PutObjectFunc(in1, in2, in3, in4, in5)
|
|
|
|
}
|
2017-05-08 23:07:07 +02:00
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// PutObjectCalls gets all the calls that were made to PutObject.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.PutObjectCalls())
|
|
|
|
func (mock *S3Mock) PutObjectCalls() []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 io.Reader
|
|
|
|
In4 int64
|
|
|
|
In5 minio.PutObjectOptions
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
In3 io.Reader
|
|
|
|
In4 int64
|
|
|
|
In5 minio.PutObjectOptions
|
|
|
|
}
|
|
|
|
lockS3MockPutObject.RLock()
|
|
|
|
calls = mock.calls.PutObject
|
|
|
|
lockS3MockPutObject.RUnlock()
|
|
|
|
return calls
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// RemoveBucket calls RemoveBucketFunc.
|
|
|
|
func (mock *S3Mock) RemoveBucket(in1 string) error {
|
|
|
|
if mock.RemoveBucketFunc == nil {
|
|
|
|
panic("moq: S3Mock.RemoveBucketFunc is nil but S3.RemoveBucket was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
}
|
|
|
|
lockS3MockRemoveBucket.Lock()
|
|
|
|
mock.calls.RemoveBucket = append(mock.calls.RemoveBucket, callInfo)
|
|
|
|
lockS3MockRemoveBucket.Unlock()
|
|
|
|
return mock.RemoveBucketFunc(in1)
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// RemoveBucketCalls gets all the calls that were made to RemoveBucket.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.RemoveBucketCalls())
|
|
|
|
func (mock *S3Mock) RemoveBucketCalls() []struct {
|
|
|
|
In1 string
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
}
|
|
|
|
lockS3MockRemoveBucket.RLock()
|
|
|
|
calls = mock.calls.RemoveBucket
|
|
|
|
lockS3MockRemoveBucket.RUnlock()
|
|
|
|
return calls
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// RemoveObject calls RemoveObjectFunc.
|
|
|
|
func (mock *S3Mock) RemoveObject(in1 string, in2 string) error {
|
|
|
|
if mock.RemoveObjectFunc == nil {
|
|
|
|
panic("moq: S3Mock.RemoveObjectFunc is nil but S3.RemoveObject was just called")
|
|
|
|
}
|
|
|
|
callInfo := struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
}{
|
|
|
|
In1: in1,
|
|
|
|
In2: in2,
|
|
|
|
}
|
|
|
|
lockS3MockRemoveObject.Lock()
|
|
|
|
mock.calls.RemoveObject = append(mock.calls.RemoveObject, callInfo)
|
|
|
|
lockS3MockRemoveObject.Unlock()
|
|
|
|
return mock.RemoveObjectFunc(in1, in2)
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|
|
|
|
|
2018-04-24 22:35:21 +02:00
|
|
|
// RemoveObjectCalls gets all the calls that were made to RemoveObject.
|
|
|
|
// Check the length with:
|
|
|
|
// len(mockedS3.RemoveObjectCalls())
|
|
|
|
func (mock *S3Mock) RemoveObjectCalls() []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
} {
|
|
|
|
var calls []struct {
|
|
|
|
In1 string
|
|
|
|
In2 string
|
|
|
|
}
|
|
|
|
lockS3MockRemoveObject.RLock()
|
|
|
|
calls = mock.calls.RemoveObject
|
|
|
|
lockS3MockRemoveObject.RUnlock()
|
|
|
|
return calls
|
2017-05-08 23:07:07 +02:00
|
|
|
}
|