You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
minio/pkg/storage/drivers/mocks/Driver.go

116 lines
2.7 KiB

package mocks
import (
"bytes"
"io"
"github.com/minio-io/minio/pkg/iodine"
"github.com/minio-io/minio/pkg/storage/drivers"
"github.com/stretchr/testify/mock"
)
// Driver is a mock
type Driver struct {
mock.Mock
ObjectWriterData map[string][]byte
}
// ListBuckets is a mock
func (m *Driver) ListBuckets() ([]drivers.BucketMetadata, error) {
ret := m.Called()
r0 := ret.Get(0).([]drivers.BucketMetadata)
r1 := ret.Error(1)
return r0, r1
}
// CreateBucket is a mock
func (m *Driver) CreateBucket(bucket, acl string) error {
ret := m.Called(bucket, acl)
r0 := ret.Error(0)
return r0
}
// GetBucketMetadata is a mock
func (m *Driver) GetBucketMetadata(bucket string) (drivers.BucketMetadata, error) {
ret := m.Called(bucket)
r0 := ret.Get(0).(drivers.BucketMetadata)
r1 := ret.Error(1)
return r0, r1
}
// SetGetObjectWriter is a mock
func (m *Driver) SetGetObjectWriter(bucket, object string, data []byte) {
m.ObjectWriterData[bucket+":"+object] = data
// println(string(m.ObjectWriterData["bucket:object"]))
}
// GetObject is a mock
func (m *Driver) GetObject(w io.Writer, bucket string, object string) (int64, error) {
ret := m.Called(w, bucket, object)
r0 := ret.Get(0).(int64)
r1 := ret.Error(1)
if r1 == nil {
if obj, ok := m.ObjectWriterData[bucket+":"+object]; ok {
n, _ := io.Copy(w, bytes.NewBuffer(obj))
r0 = n
}
}
return r0, r1
}
// GetPartialObject is a mock
func (m *Driver) GetPartialObject(w io.Writer, bucket string, object string, start int64, length int64) (int64, error) {
ret := m.Called(w, bucket, object, start, length)
r0 := ret.Get(0).(int64)
r1 := ret.Error(1)
if r1 == nil {
if obj, ok := m.ObjectWriterData[bucket+":"+object]; ok {
source := bytes.NewBuffer(obj)
var nilSink bytes.Buffer
io.CopyN(&nilSink, source, start)
n, _ := io.CopyN(w, source, length)
r0 = n
}
}
r1 = iodine.New(r1, nil)
return r0, r1
}
// GetObjectMetadata is a mock
func (m *Driver) GetObjectMetadata(bucket string, object string, prefix string) (drivers.ObjectMetadata, error) {
ret := m.Called(bucket, object, prefix)
r0 := ret.Get(0).(drivers.ObjectMetadata)
r1 := ret.Error(1)
return r0, r1
}
// ListObjects is a mock
func (m *Driver) ListObjects(bucket string, resources drivers.BucketResourcesMetadata) ([]drivers.ObjectMetadata, drivers.BucketResourcesMetadata, error) {
ret := m.Called(bucket, resources)
r0 := ret.Get(0).([]drivers.ObjectMetadata)
r1 := ret.Get(1).(drivers.BucketResourcesMetadata)
r2 := ret.Error(2)
return r0, r1, r2
}
// CreateObject is a mock
func (m *Driver) CreateObject(bucket string, key string, contentType string, md5sum string, data io.Reader) error {
ret := m.Called(bucket, key, contentType, md5sum, data)
r0 := ret.Error(0)
return r0
}