miniogw: log all errors (#182)
* miniogw: log all errors * tests added * doc comment to satisfy linter * fix test failure
This commit is contained in:
parent
6ea6252be8
commit
389e65d742
@ -12,6 +12,7 @@ import (
|
||||
"github.com/vivint/infectious"
|
||||
|
||||
"storj.io/storj/pkg/eestream"
|
||||
"storj.io/storj/pkg/miniogw/logging"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/pkg/provider"
|
||||
@ -136,6 +137,7 @@ func (c Config) action(ctx context.Context, cliCtx *cli.Context,
|
||||
// TODO: passthrough is bad
|
||||
stream := streams.NewPassthrough(segments)
|
||||
|
||||
minio.StartGateway(cliCtx, NewStorjGateway(objects.NewStore(stream)))
|
||||
minio.StartGateway(cliCtx, logging.Gateway(
|
||||
NewStorjGateway(objects.NewStore(stream))))
|
||||
return Error.New("unexpected minio exit")
|
||||
}
|
||||
|
76
pkg/miniogw/logging/gw_mock_test.go
Normal file
76
pkg/miniogw/logging/gw_mock_test.go
Normal file
@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/minio/minio/cmd (interfaces: Gateway)
|
||||
|
||||
// Package logging is a generated GoMock package.
|
||||
package logging
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cmd "github.com/minio/minio/cmd"
|
||||
auth "github.com/minio/minio/pkg/auth"
|
||||
)
|
||||
|
||||
// MockGateway is a mock of Gateway interface
|
||||
type MockGateway struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockGatewayMockRecorder
|
||||
}
|
||||
|
||||
// MockGatewayMockRecorder is the mock recorder for MockGateway
|
||||
type MockGatewayMockRecorder struct {
|
||||
mock *MockGateway
|
||||
}
|
||||
|
||||
// NewMockGateway creates a new mock instance
|
||||
func NewMockGateway(ctrl *gomock.Controller) *MockGateway {
|
||||
mock := &MockGateway{ctrl: ctrl}
|
||||
mock.recorder = &MockGatewayMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockGateway) EXPECT() *MockGatewayMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Name mocks base method
|
||||
func (m *MockGateway) Name() string {
|
||||
ret := m.ctrl.Call(m, "Name")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Name indicates an expected call of Name
|
||||
func (mr *MockGatewayMockRecorder) Name() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockGateway)(nil).Name))
|
||||
}
|
||||
|
||||
// NewGatewayLayer mocks base method
|
||||
func (m *MockGateway) NewGatewayLayer(arg0 auth.Credentials) (cmd.ObjectLayer, error) {
|
||||
ret := m.ctrl.Call(m, "NewGatewayLayer", arg0)
|
||||
ret0, _ := ret[0].(cmd.ObjectLayer)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// NewGatewayLayer indicates an expected call of NewGatewayLayer
|
||||
func (mr *MockGatewayMockRecorder) NewGatewayLayer(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewGatewayLayer", reflect.TypeOf((*MockGateway)(nil).NewGatewayLayer), arg0)
|
||||
}
|
||||
|
||||
// Production mocks base method
|
||||
func (m *MockGateway) Production() bool {
|
||||
ret := m.ctrl.Call(m, "Production")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Production indicates an expected call of Production
|
||||
func (mr *MockGatewayMockRecorder) Production() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Production", reflect.TypeOf((*MockGateway)(nil).Production))
|
||||
}
|
52
pkg/miniogw/logging/logger_mock_test.go
Normal file
52
pkg/miniogw/logging/logger_mock_test.go
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: storj.io/storj/pkg/miniogw/logging (interfaces: ErrorLogger)
|
||||
|
||||
// Package logging is a generated GoMock package.
|
||||
package logging
|
||||
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// MockErrorLogger is a mock of ErrorLogger interface
|
||||
type MockErrorLogger struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockErrorLoggerMockRecorder
|
||||
}
|
||||
|
||||
// MockErrorLoggerMockRecorder is the mock recorder for MockErrorLogger
|
||||
type MockErrorLoggerMockRecorder struct {
|
||||
mock *MockErrorLogger
|
||||
}
|
||||
|
||||
// NewMockErrorLogger creates a new mock instance
|
||||
func NewMockErrorLogger(ctrl *gomock.Controller) *MockErrorLogger {
|
||||
mock := &MockErrorLogger{ctrl: ctrl}
|
||||
mock.recorder = &MockErrorLoggerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockErrorLogger) EXPECT() *MockErrorLoggerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Errorf mocks base method
|
||||
func (m *MockErrorLogger) Errorf(arg0 string, arg1 ...interface{}) {
|
||||
varargs := []interface{}{arg0}
|
||||
for _, a := range arg1 {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
m.ctrl.Call(m, "Errorf", varargs...)
|
||||
}
|
||||
|
||||
// Errorf indicates an expected call of Errorf
|
||||
func (mr *MockErrorLoggerMockRecorder) Errorf(arg0 interface{}, arg1 ...interface{}) *gomock.Call {
|
||||
varargs := append([]interface{}{arg0}, arg1...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Errorf", reflect.TypeOf((*MockErrorLogger)(nil).Errorf), varargs...)
|
||||
}
|
254
pkg/miniogw/logging/logging.go
Normal file
254
pkg/miniogw/logging/logging.go
Normal file
@ -0,0 +1,254 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
context "context"
|
||||
io "io"
|
||||
"time"
|
||||
|
||||
minio "github.com/minio/minio/cmd"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/hash"
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
"github.com/minio/minio/pkg/policy"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var errTemplate = "gateway error: %+v"
|
||||
|
||||
type gwLogWrap struct {
|
||||
gw minio.Gateway
|
||||
}
|
||||
|
||||
// Gateway is a wrapper of minio.Gateway that logs errors before
|
||||
// returning them.
|
||||
func Gateway(gw minio.Gateway) minio.Gateway {
|
||||
return &gwLogWrap{gw: gw}
|
||||
}
|
||||
|
||||
func (lg *gwLogWrap) Name() string { return lg.gw.Name() }
|
||||
func (lg *gwLogWrap) Production() bool { return lg.gw.Production() }
|
||||
func (lg *gwLogWrap) NewGatewayLayer(creds auth.Credentials) (
|
||||
minio.ObjectLayer, error) {
|
||||
ol, err := lg.gw.NewGatewayLayer(creds)
|
||||
return &olLogWrap{ol: ol, logger: zap.S()}, err
|
||||
}
|
||||
|
||||
type olLogWrap struct {
|
||||
ol minio.ObjectLayer
|
||||
logger ErrorLogger
|
||||
}
|
||||
|
||||
// ErrorLogger logs a templated error message
|
||||
type ErrorLogger interface {
|
||||
Errorf(template string, args ...interface{})
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) wrap(err error) error {
|
||||
if err != nil {
|
||||
ol.logger.Errorf(errTemplate, err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) Shutdown(ctx context.Context) error {
|
||||
return ol.wrap(ol.ol.Shutdown(ctx))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) StorageInfo(ctx context.Context) minio.StorageInfo {
|
||||
return ol.ol.StorageInfo(ctx)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) MakeBucketWithLocation(ctx context.Context,
|
||||
bucket string, location string) error {
|
||||
return ol.wrap(ol.ol.MakeBucketWithLocation(ctx, bucket, location))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) GetBucketInfo(ctx context.Context, bucket string) (
|
||||
bucketInfo minio.BucketInfo, err error) {
|
||||
bucketInfo, err = ol.ol.GetBucketInfo(ctx, bucket)
|
||||
return bucketInfo, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListBuckets(ctx context.Context) (
|
||||
buckets []minio.BucketInfo, err error) {
|
||||
buckets, err = ol.ol.ListBuckets(ctx)
|
||||
return buckets, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) DeleteBucket(ctx context.Context, bucket string) error {
|
||||
return ol.wrap(ol.ol.DeleteBucket(ctx, bucket))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListObjects(ctx context.Context,
|
||||
bucket, prefix, marker, delimiter string, maxKeys int) (
|
||||
result minio.ListObjectsInfo, err error) {
|
||||
result, err = ol.ol.ListObjects(ctx, bucket, prefix, marker, delimiter,
|
||||
maxKeys)
|
||||
return result, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListObjectsV2(ctx context.Context,
|
||||
bucket, prefix, continuationToken, delimiter string, maxKeys int,
|
||||
fetchOwner bool, startAfter string) (result minio.ListObjectsV2Info,
|
||||
err error) {
|
||||
result, err = ol.ol.ListObjectsV2(ctx, bucket, prefix, continuationToken,
|
||||
delimiter, maxKeys, fetchOwner, startAfter)
|
||||
return result, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) GetObject(ctx context.Context, bucket, object string,
|
||||
startOffset int64, length int64, writer io.Writer, etag string) (err error) {
|
||||
return ol.wrap(ol.ol.GetObject(ctx, bucket, object, startOffset, length,
|
||||
writer, etag))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) GetObjectInfo(ctx context.Context, bucket, object string) (
|
||||
objInfo minio.ObjectInfo, err error) {
|
||||
objInfo, err = ol.ol.GetObjectInfo(ctx, bucket, object)
|
||||
return objInfo, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) PutObject(ctx context.Context, bucket, object string,
|
||||
data *hash.Reader, metadata map[string]string) (objInfo minio.ObjectInfo,
|
||||
err error) {
|
||||
objInfo, err = ol.ol.PutObject(ctx, bucket, object, data, metadata)
|
||||
return objInfo, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) CopyObject(ctx context.Context,
|
||||
srcBucket, srcObject, destBucket, destObject string,
|
||||
srcInfo minio.ObjectInfo) (objInfo minio.ObjectInfo, err error) {
|
||||
objInfo, err = ol.ol.CopyObject(ctx, srcBucket, srcObject, destBucket,
|
||||
destObject, srcInfo)
|
||||
return objInfo, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) DeleteObject(ctx context.Context, bucket, object string) (
|
||||
err error) {
|
||||
return ol.wrap(ol.ol.DeleteObject(ctx, bucket, object))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListMultipartUploads(ctx context.Context,
|
||||
bucket, prefix, keyMarker, uploadIDMarker, delimiter string, maxUploads int) (
|
||||
result minio.ListMultipartsInfo, err error) {
|
||||
result, err = ol.ol.ListMultipartUploads(ctx, bucket, prefix, keyMarker,
|
||||
uploadIDMarker, delimiter, maxUploads)
|
||||
return result, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) NewMultipartUpload(ctx context.Context,
|
||||
bucket, object string, metadata map[string]string) (uploadID string,
|
||||
err error) {
|
||||
uploadID, err = ol.ol.NewMultipartUpload(ctx, bucket, object, metadata)
|
||||
return uploadID, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) CopyObjectPart(ctx context.Context,
|
||||
srcBucket, srcObject, destBucket, destObject string, uploadID string,
|
||||
partID int, startOffset int64, length int64, srcInfo minio.ObjectInfo) (
|
||||
info minio.PartInfo, err error) {
|
||||
info, err = ol.ol.CopyObjectPart(ctx, srcBucket, srcObject, destBucket,
|
||||
destObject, uploadID, partID, startOffset, length, srcInfo)
|
||||
return info, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) PutObjectPart(ctx context.Context,
|
||||
bucket, object, uploadID string, partID int, data *hash.Reader) (
|
||||
info minio.PartInfo, err error) {
|
||||
info, err = ol.ol.PutObjectPart(ctx, bucket, object, uploadID, partID, data)
|
||||
return info, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListObjectParts(ctx context.Context,
|
||||
bucket, object, uploadID string, partNumberMarker int, maxParts int) (
|
||||
result minio.ListPartsInfo, err error) {
|
||||
result, err = ol.ol.ListObjectParts(ctx, bucket, object, uploadID,
|
||||
partNumberMarker, maxParts)
|
||||
return result, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) AbortMultipartUpload(ctx context.Context,
|
||||
bucket, object, uploadID string) error {
|
||||
return ol.wrap(ol.ol.AbortMultipartUpload(ctx, bucket, object, uploadID))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) CompleteMultipartUpload(ctx context.Context,
|
||||
bucket, object, uploadID string, uploadedParts []minio.CompletePart) (
|
||||
objInfo minio.ObjectInfo, err error) {
|
||||
objInfo, err = ol.ol.CompleteMultipartUpload(ctx, bucket, object, uploadID,
|
||||
uploadedParts)
|
||||
return objInfo, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ReloadFormat(ctx context.Context, dryRun bool) error {
|
||||
return ol.wrap(ol.ol.ReloadFormat(ctx, dryRun))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) HealFormat(ctx context.Context, dryRun bool) (
|
||||
madmin.HealResultItem, error) {
|
||||
rv, err := ol.ol.HealFormat(ctx, dryRun)
|
||||
return rv, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) HealBucket(ctx context.Context, bucket string,
|
||||
dryRun bool) ([]madmin.HealResultItem, error) {
|
||||
rv, err := ol.ol.HealBucket(ctx, bucket, dryRun)
|
||||
return rv, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) HealObject(ctx context.Context, bucket, object string,
|
||||
dryRun bool) (madmin.HealResultItem, error) {
|
||||
rv, err := ol.ol.HealObject(ctx, bucket, object, dryRun)
|
||||
return rv, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListBucketsHeal(ctx context.Context) (
|
||||
buckets []minio.BucketInfo, err error) {
|
||||
buckets, err = ol.ol.ListBucketsHeal(ctx)
|
||||
return buckets, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListObjectsHeal(ctx context.Context,
|
||||
bucket, prefix, marker, delimiter string, maxKeys int) (
|
||||
minio.ListObjectsInfo, error) {
|
||||
rv, err := ol.ol.ListObjectsHeal(ctx, bucket, prefix, marker, delimiter,
|
||||
maxKeys)
|
||||
return rv, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ListLocks(ctx context.Context, bucket, prefix string,
|
||||
duration time.Duration) ([]minio.VolumeLockInfo, error) {
|
||||
rv, err := ol.ol.ListLocks(ctx, bucket, prefix, duration)
|
||||
return rv, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) ClearLocks(ctx context.Context,
|
||||
lockInfos []minio.VolumeLockInfo) error {
|
||||
return ol.wrap(ol.ol.ClearLocks(ctx, lockInfos))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) SetBucketPolicy(ctx context.Context, n string,
|
||||
p *policy.Policy) error {
|
||||
return ol.wrap(ol.ol.SetBucketPolicy(ctx, n, p))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) GetBucketPolicy(ctx context.Context, n string) (
|
||||
*policy.Policy, error) {
|
||||
p, err := ol.ol.GetBucketPolicy(ctx, n)
|
||||
return p, ol.wrap(err)
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) DeleteBucketPolicy(ctx context.Context, n string) error {
|
||||
return ol.wrap(ol.ol.DeleteBucketPolicy(ctx, n))
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) IsNotificationSupported() bool {
|
||||
return ol.ol.IsNotificationSupported()
|
||||
}
|
||||
|
||||
func (ol *olLogWrap) IsEncryptionSupported() bool {
|
||||
return ol.ol.IsEncryptionSupported()
|
||||
}
|
778
pkg/miniogw/logging/logging_test.go
Normal file
778
pkg/miniogw/logging/logging_test.go
Normal file
@ -0,0 +1,778 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package logging
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
policy "github.com/minio/minio/pkg/policy"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
minio "github.com/minio/minio/cmd"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/hash"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const (
|
||||
testError = "test error"
|
||||
bucket = "test-bucket"
|
||||
object = "test-object"
|
||||
destBucket = "dest-bucket"
|
||||
destObject = "dest-object"
|
||||
prefix = "test-prefix"
|
||||
marker = "test-marker"
|
||||
partMarker = 42
|
||||
delimiter = "test-delimiter"
|
||||
maxKeys = 1234
|
||||
offset = int64(12)
|
||||
length = int64(34)
|
||||
uploadID = "test-upload-id"
|
||||
partID = 9876
|
||||
dryRun = true
|
||||
duration = 12 * time.Second
|
||||
n = "test-n"
|
||||
)
|
||||
|
||||
var (
|
||||
ctx = context.Background()
|
||||
ErrTest = errors.New(testError)
|
||||
metadata = map[string]string{"key": "value"}
|
||||
)
|
||||
|
||||
var (
|
||||
bucketInfo = minio.BucketInfo{Name: bucket}
|
||||
bucketList = []minio.BucketInfo{bucketInfo}
|
||||
objInfo = minio.ObjectInfo{Bucket: bucket, Name: object}
|
||||
objList = minio.ListObjectsInfo{Objects: []minio.ObjectInfo{objInfo}}
|
||||
objListV2 = minio.ListObjectsV2Info{Objects: []minio.ObjectInfo{objInfo}}
|
||||
destObjInfo = minio.ObjectInfo{Bucket: destBucket, Name: destObject}
|
||||
partInfo = minio.PartInfo{PartNumber: partID}
|
||||
partList = minio.ListPartsInfo{Parts: []minio.PartInfo{partInfo}}
|
||||
healItem = madmin.HealResultItem{Bucket: bucket, Object: object}
|
||||
healList = []madmin.HealResultItem{healItem}
|
||||
lockList = []minio.VolumeLockInfo{minio.VolumeLockInfo{Bucket: bucket, Object: object}}
|
||||
plcy = &policy.Policy{ID: n}
|
||||
)
|
||||
|
||||
func TestGateway(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
gw := NewMockGateway(mockCtrl)
|
||||
lgw := Gateway(gw)
|
||||
|
||||
// Test Name()
|
||||
name := "GatewayName"
|
||||
gw.EXPECT().Name().Return(name)
|
||||
assert.Equal(t, name, lgw.Name())
|
||||
|
||||
// Test Production()
|
||||
production := true
|
||||
gw.EXPECT().Production().Return(production)
|
||||
assert.Equal(t, production, lgw.Production())
|
||||
|
||||
// Test NewGatewayLayer() returning without error
|
||||
creds := auth.Credentials{
|
||||
AccessKey: "test-access-key",
|
||||
SecretKey: "test-secret-key",
|
||||
}
|
||||
mol := NewMockObjectLayer(mockCtrl)
|
||||
gw.EXPECT().NewGatewayLayer(creds).Return(mol, nil)
|
||||
ol, err := lgw.NewGatewayLayer(creds)
|
||||
assert.NoError(t, err)
|
||||
olw, ok := ol.(*olLogWrap)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, mol, olw.ol)
|
||||
assert.Equal(t, zap.S(), olw.logger)
|
||||
|
||||
// Test NewGatewayLayer() returning error
|
||||
gw.EXPECT().NewGatewayLayer(creds).Return(nil, ErrTest)
|
||||
_, err = lgw.NewGatewayLayer(creds)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestShutdown(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().Shutdown(ctx).Return(nil)
|
||||
err := ol.Shutdown(ctx)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().Shutdown(ctx).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.Shutdown(ctx)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestStorageInfo(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
_, mol, ol := initMocks(mockCtrl)
|
||||
storageInfo := minio.StorageInfo{}
|
||||
|
||||
mol.EXPECT().StorageInfo(ctx).Return(storageInfo)
|
||||
info := ol.StorageInfo(ctx)
|
||||
assert.Equal(t, storageInfo, info)
|
||||
}
|
||||
|
||||
func TestMakeBucketWithLocation(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
location := "test-location"
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().MakeBucketWithLocation(ctx, bucket, location).Return(nil)
|
||||
err := ol.MakeBucketWithLocation(ctx, bucket, location)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().MakeBucketWithLocation(ctx, bucket, location).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.MakeBucketWithLocation(ctx, bucket, location)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestGetBucketInfo(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().GetBucketInfo(ctx, bucket).Return(bucketInfo, nil)
|
||||
info, err := ol.GetBucketInfo(ctx, bucket)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bucketInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().GetBucketInfo(ctx, bucket).Return(minio.BucketInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.GetBucketInfo(ctx, bucket)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.BucketInfo{}, info)
|
||||
}
|
||||
|
||||
func TestListBuckets(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListBuckets(ctx).Return(bucketList, nil)
|
||||
list, err := ol.ListBuckets(ctx)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bucketList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListBuckets(ctx).Return([]minio.BucketInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListBuckets(ctx)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, []minio.BucketInfo{}, list)
|
||||
}
|
||||
|
||||
func TestDeleteBucket(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().DeleteBucket(ctx, bucket).Return(nil)
|
||||
err := ol.DeleteBucket(ctx, bucket)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().DeleteBucket(ctx, bucket).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.DeleteBucket(ctx, bucket)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestListObjects(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListObjects(ctx, bucket, prefix, marker, delimiter, maxKeys).
|
||||
Return(objList, nil)
|
||||
list, err := ol.ListObjects(ctx, bucket, prefix, marker, delimiter, maxKeys)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListObjects(ctx, bucket, prefix, marker, delimiter, maxKeys).
|
||||
Return(minio.ListObjectsInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListObjects(ctx, bucket, prefix, marker, delimiter, maxKeys)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ListObjectsInfo{}, list)
|
||||
}
|
||||
|
||||
func TestListObjectsV2(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
token := "test-token"
|
||||
owner := true
|
||||
startAfter := "test-after"
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListObjectsV2(ctx, bucket, prefix, token, delimiter, maxKeys,
|
||||
owner, startAfter).Return(objListV2, nil)
|
||||
list, err := ol.ListObjectsV2(ctx, bucket, prefix, token, delimiter,
|
||||
maxKeys, owner, startAfter)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objListV2, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListObjectsV2(ctx, bucket, prefix, marker, delimiter, maxKeys,
|
||||
owner, startAfter).Return(minio.ListObjectsV2Info{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListObjectsV2(ctx, bucket, prefix, marker, delimiter,
|
||||
maxKeys, owner, startAfter)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ListObjectsV2Info{}, list)
|
||||
}
|
||||
|
||||
func TestGetObject(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
w := ioutil.Discard
|
||||
etag := "test-etag"
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().GetObject(ctx, bucket, object, offset, length, w, etag).Return(nil)
|
||||
err := ol.GetObject(ctx, bucket, object, offset, length, w, etag)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().GetObject(ctx, bucket, object, offset, length, w, etag).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.GetObject(ctx, bucket, object, offset, length, w, etag)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestGetObjectInfo(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().GetObjectInfo(ctx, bucket, object).Return(objInfo, nil)
|
||||
info, err := ol.GetObjectInfo(ctx, bucket, object)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().GetObjectInfo(ctx, bucket, object).Return(minio.ObjectInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.GetObjectInfo(ctx, bucket, object)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ObjectInfo{}, info)
|
||||
}
|
||||
|
||||
func TestPutObject(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
data := initHashReader(t)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().PutObject(ctx, bucket, object, data, metadata).Return(objInfo, nil)
|
||||
info, err := ol.PutObject(ctx, bucket, object, data, metadata)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().PutObject(ctx, bucket, object, data, metadata).Return(minio.ObjectInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.PutObject(ctx, bucket, object, data, metadata)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ObjectInfo{}, info)
|
||||
}
|
||||
|
||||
func TestCopyObject(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().CopyObject(ctx, bucket, object, destBucket, destObject, objInfo).
|
||||
Return(destObjInfo, nil)
|
||||
info, err := ol.CopyObject(ctx, bucket, object, destBucket, destObject, objInfo)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, destObjInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().CopyObject(ctx, bucket, object, destBucket, destObject, objInfo).
|
||||
Return(minio.ObjectInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.CopyObject(ctx, bucket, object, destBucket, destObject, objInfo)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ObjectInfo{}, info)
|
||||
}
|
||||
|
||||
func TestDeleteObject(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().DeleteObject(ctx, bucket, object).Return(nil)
|
||||
err := ol.DeleteObject(ctx, bucket, object)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().DeleteObject(ctx, bucket, object).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.DeleteObject(ctx, bucket, object)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestListMultipartUploads(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
uidMarker := "test-upload-id-marker"
|
||||
listMultiParts := minio.ListMultipartsInfo{
|
||||
Uploads: []minio.MultipartInfo{minio.MultipartInfo{Object: object}}}
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListMultipartUploads(ctx, bucket, prefix, marker, uidMarker,
|
||||
delimiter, maxKeys).Return(listMultiParts, nil)
|
||||
list, err := ol.ListMultipartUploads(ctx, bucket, prefix, marker,
|
||||
uidMarker, delimiter, maxKeys)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, listMultiParts, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListMultipartUploads(ctx, bucket, prefix, marker, uidMarker,
|
||||
delimiter, maxKeys).Return(minio.ListMultipartsInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListMultipartUploads(ctx, bucket, prefix, marker, uidMarker,
|
||||
delimiter, maxKeys)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ListMultipartsInfo{}, list)
|
||||
}
|
||||
|
||||
func TestNewMultipartUpload(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().NewMultipartUpload(ctx, bucket, object, metadata).Return(uploadID, nil)
|
||||
id, err := ol.NewMultipartUpload(ctx, bucket, object, metadata)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, uploadID, id)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().NewMultipartUpload(ctx, bucket, object, metadata).Return("", ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
id, err = ol.NewMultipartUpload(ctx, bucket, object, metadata)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, "", id)
|
||||
}
|
||||
|
||||
func TestCopyObjectPart(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().CopyObjectPart(ctx, bucket, object, destBucket, destObject,
|
||||
uploadID, partID, offset, length, objInfo).Return(partInfo, nil)
|
||||
info, err := ol.CopyObjectPart(ctx, bucket, object, destBucket, destObject,
|
||||
uploadID, partID, offset, length, objInfo)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, partInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().CopyObjectPart(ctx, bucket, object, destBucket, destObject,
|
||||
uploadID, partID, offset, length, objInfo).Return(minio.PartInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.CopyObjectPart(ctx, bucket, object, destBucket, destObject,
|
||||
uploadID, partID, offset, length, objInfo)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.PartInfo{}, info)
|
||||
}
|
||||
|
||||
func TestPutObjectPart(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
data := initHashReader(t)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().PutObjectPart(ctx, bucket, object, uploadID, partID, data).
|
||||
Return(partInfo, nil)
|
||||
info, err := ol.PutObjectPart(ctx, bucket, object, uploadID, partID, data)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, partInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().PutObjectPart(ctx, bucket, object, uploadID, partID, data).
|
||||
Return(minio.PartInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.PutObjectPart(ctx, bucket, object, uploadID, partID, data)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.PartInfo{}, info)
|
||||
}
|
||||
|
||||
func TestListObjectParts(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListObjectParts(ctx, bucket, object, uploadID, partMarker, maxKeys).
|
||||
Return(partList, nil)
|
||||
list, err := ol.ListObjectParts(ctx, bucket, object, uploadID, partMarker, maxKeys)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, partList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListObjectParts(ctx, bucket, object, uploadID, partMarker, maxKeys).
|
||||
Return(minio.ListPartsInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListObjectParts(ctx, bucket, object, uploadID, partMarker, maxKeys)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ListPartsInfo{}, list)
|
||||
}
|
||||
|
||||
func TestAbortMultipartUpload(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().AbortMultipartUpload(ctx, bucket, object, uploadID).Return(nil)
|
||||
err := ol.AbortMultipartUpload(ctx, bucket, object, uploadID)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().AbortMultipartUpload(ctx, bucket, object, uploadID).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.AbortMultipartUpload(ctx, bucket, object, uploadID)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestCompleteMultipartUpload(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
parts := []minio.CompletePart{minio.CompletePart{PartNumber: partID}}
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().CompleteMultipartUpload(ctx, bucket, object, uploadID, parts).
|
||||
Return(objInfo, nil)
|
||||
info, err := ol.CompleteMultipartUpload(ctx, bucket, object, uploadID, parts)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objInfo, info)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().CompleteMultipartUpload(ctx, bucket, object, uploadID, parts).
|
||||
Return(minio.ObjectInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
info, err = ol.CompleteMultipartUpload(ctx, bucket, object, uploadID, parts)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ObjectInfo{}, info)
|
||||
}
|
||||
|
||||
func TestReloadFormat(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ReloadFormat(ctx, dryRun).Return(nil)
|
||||
err := ol.ReloadFormat(ctx, dryRun)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ReloadFormat(ctx, dryRun).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.ReloadFormat(ctx, dryRun)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestHealFormat(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().HealFormat(ctx, dryRun).Return(healItem, nil)
|
||||
item, err := ol.HealFormat(ctx, dryRun)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, healItem, item)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().HealFormat(ctx, dryRun).Return(madmin.HealResultItem{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
item, err = ol.HealFormat(ctx, dryRun)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, madmin.HealResultItem{}, item)
|
||||
}
|
||||
|
||||
func TestHealBucket(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().HealBucket(ctx, bucket, dryRun).Return(healList, nil)
|
||||
list, err := ol.HealBucket(ctx, bucket, dryRun)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, healList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().HealBucket(ctx, bucket, dryRun).Return([]madmin.HealResultItem{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.HealBucket(ctx, bucket, dryRun)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, []madmin.HealResultItem{}, list)
|
||||
}
|
||||
|
||||
func TestHealObject(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().HealObject(ctx, bucket, object, dryRun).Return(healItem, nil)
|
||||
item, err := ol.HealObject(ctx, bucket, object, dryRun)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, healItem, item)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().HealObject(ctx, bucket, object, dryRun).Return(madmin.HealResultItem{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
item, err = ol.HealObject(ctx, bucket, object, dryRun)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, madmin.HealResultItem{}, item)
|
||||
}
|
||||
|
||||
func TestListBucketsHeal(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListBucketsHeal(ctx).Return(bucketList, nil)
|
||||
list, err := ol.ListBucketsHeal(ctx)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, bucketList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListBucketsHeal(ctx).Return([]minio.BucketInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListBucketsHeal(ctx)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, []minio.BucketInfo{}, list)
|
||||
}
|
||||
|
||||
func TestListObjectsHeal(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListObjectsHeal(ctx, bucket, prefix, marker, delimiter, maxKeys).
|
||||
Return(objList, nil)
|
||||
list, err := ol.ListObjectsHeal(ctx, bucket, prefix, marker, delimiter, maxKeys)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, objList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListObjectsHeal(ctx, bucket, prefix, marker, delimiter, maxKeys).
|
||||
Return(minio.ListObjectsInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListObjectsHeal(ctx, bucket, prefix, marker, delimiter, maxKeys)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, minio.ListObjectsInfo{}, list)
|
||||
}
|
||||
|
||||
func TestListLocks(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ListLocks(ctx, bucket, prefix, duration).Return(lockList, nil)
|
||||
list, err := ol.ListLocks(ctx, bucket, prefix, duration)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, lockList, list)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ListLocks(ctx, bucket, prefix, duration).
|
||||
Return([]minio.VolumeLockInfo{}, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
list, err = ol.ListLocks(ctx, bucket, prefix, duration)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Equal(t, []minio.VolumeLockInfo{}, list)
|
||||
}
|
||||
|
||||
func TestClearLocks(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().ClearLocks(ctx, lockList).Return(nil)
|
||||
err := ol.ClearLocks(ctx, lockList)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().ClearLocks(ctx, lockList).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.ClearLocks(ctx, lockList)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestSetBucketPolicy(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().SetBucketPolicy(ctx, n, plcy).Return(nil)
|
||||
err := ol.SetBucketPolicy(ctx, n, plcy)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().SetBucketPolicy(ctx, n, plcy).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.SetBucketPolicy(ctx, n, plcy)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestGetBucketPolicy(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().GetBucketPolicy(ctx, n).Return(plcy, nil)
|
||||
p, err := ol.GetBucketPolicy(ctx, n)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, plcy, p)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().GetBucketPolicy(ctx, n).Return(nil, ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
p, err = ol.GetBucketPolicy(ctx, n)
|
||||
assert.Error(t, err, testError)
|
||||
assert.Nil(t, p)
|
||||
}
|
||||
|
||||
func TestDeleteBucketPolicy(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
logger, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
// No error returned
|
||||
mol.EXPECT().DeleteBucketPolicy(ctx, n).Return(nil)
|
||||
err := ol.DeleteBucketPolicy(ctx, n)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Error returned
|
||||
mol.EXPECT().DeleteBucketPolicy(ctx, n).Return(ErrTest)
|
||||
logger.EXPECT().Errorf(errTemplate, ErrTest)
|
||||
err = ol.DeleteBucketPolicy(ctx, n)
|
||||
assert.Error(t, err, testError)
|
||||
}
|
||||
|
||||
func TestIsNotificationSupported(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
_, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
mol.EXPECT().IsNotificationSupported().Return(true)
|
||||
assert.True(t, ol.IsNotificationSupported())
|
||||
|
||||
mol.EXPECT().IsNotificationSupported().Return(false)
|
||||
assert.False(t, ol.IsNotificationSupported())
|
||||
}
|
||||
|
||||
func TestIsEncryptionSupported(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
_, mol, ol := initMocks(mockCtrl)
|
||||
|
||||
mol.EXPECT().IsEncryptionSupported().Return(true)
|
||||
assert.True(t, ol.IsEncryptionSupported())
|
||||
|
||||
mol.EXPECT().IsEncryptionSupported().Return(false)
|
||||
assert.False(t, ol.IsEncryptionSupported())
|
||||
}
|
||||
|
||||
func initMocks(mockCtrl *gomock.Controller) (*MockErrorLogger, *MockObjectLayer, olLogWrap) {
|
||||
logger := NewMockErrorLogger(mockCtrl)
|
||||
mol := NewMockObjectLayer(mockCtrl)
|
||||
ol := olLogWrap{ol: mol, logger: logger}
|
||||
return logger, mol, ol
|
||||
}
|
||||
|
||||
func initHashReader(t *testing.T) *hash.Reader {
|
||||
data, err := hash.NewReader(bytes.NewReader([]byte("test")), 4,
|
||||
"d8e8fca2dc0f896fd7cb4cb0031ba249",
|
||||
"f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2")
|
||||
assert.NoError(t, err)
|
||||
return data
|
||||
}
|
460
pkg/miniogw/logging/objlayer_mock_test.go
Normal file
460
pkg/miniogw/logging/objlayer_mock_test.go
Normal file
@ -0,0 +1,460 @@
|
||||
// Copyright (C) 2018 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/minio/minio/cmd (interfaces: ObjectLayer)
|
||||
|
||||
// Package logging is a generated GoMock package.
|
||||
package logging
|
||||
|
||||
import (
|
||||
context "context"
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cmd "github.com/minio/minio/cmd"
|
||||
hash "github.com/minio/minio/pkg/hash"
|
||||
madmin "github.com/minio/minio/pkg/madmin"
|
||||
policy "github.com/minio/minio/pkg/policy"
|
||||
)
|
||||
|
||||
// MockObjectLayer is a mock of ObjectLayer interface
|
||||
type MockObjectLayer struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockObjectLayerMockRecorder
|
||||
}
|
||||
|
||||
// MockObjectLayerMockRecorder is the mock recorder for MockObjectLayer
|
||||
type MockObjectLayerMockRecorder struct {
|
||||
mock *MockObjectLayer
|
||||
}
|
||||
|
||||
// NewMockObjectLayer creates a new mock instance
|
||||
func NewMockObjectLayer(ctrl *gomock.Controller) *MockObjectLayer {
|
||||
mock := &MockObjectLayer{ctrl: ctrl}
|
||||
mock.recorder = &MockObjectLayerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockObjectLayer) EXPECT() *MockObjectLayerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AbortMultipartUpload mocks base method
|
||||
func (m *MockObjectLayer) AbortMultipartUpload(arg0 context.Context, arg1, arg2, arg3 string) error {
|
||||
ret := m.ctrl.Call(m, "AbortMultipartUpload", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AbortMultipartUpload indicates an expected call of AbortMultipartUpload
|
||||
func (mr *MockObjectLayerMockRecorder) AbortMultipartUpload(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AbortMultipartUpload", reflect.TypeOf((*MockObjectLayer)(nil).AbortMultipartUpload), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// ClearLocks mocks base method
|
||||
func (m *MockObjectLayer) ClearLocks(arg0 context.Context, arg1 []cmd.VolumeLockInfo) error {
|
||||
ret := m.ctrl.Call(m, "ClearLocks", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ClearLocks indicates an expected call of ClearLocks
|
||||
func (mr *MockObjectLayerMockRecorder) ClearLocks(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearLocks", reflect.TypeOf((*MockObjectLayer)(nil).ClearLocks), arg0, arg1)
|
||||
}
|
||||
|
||||
// CompleteMultipartUpload mocks base method
|
||||
func (m *MockObjectLayer) CompleteMultipartUpload(arg0 context.Context, arg1, arg2, arg3 string, arg4 []cmd.CompletePart) (cmd.ObjectInfo, error) {
|
||||
ret := m.ctrl.Call(m, "CompleteMultipartUpload", arg0, arg1, arg2, arg3, arg4)
|
||||
ret0, _ := ret[0].(cmd.ObjectInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CompleteMultipartUpload indicates an expected call of CompleteMultipartUpload
|
||||
func (mr *MockObjectLayerMockRecorder) CompleteMultipartUpload(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompleteMultipartUpload", reflect.TypeOf((*MockObjectLayer)(nil).CompleteMultipartUpload), arg0, arg1, arg2, arg3, arg4)
|
||||
}
|
||||
|
||||
// CopyObject mocks base method
|
||||
func (m *MockObjectLayer) CopyObject(arg0 context.Context, arg1, arg2, arg3, arg4 string, arg5 cmd.ObjectInfo) (cmd.ObjectInfo, error) {
|
||||
ret := m.ctrl.Call(m, "CopyObject", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
ret0, _ := ret[0].(cmd.ObjectInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CopyObject indicates an expected call of CopyObject
|
||||
func (mr *MockObjectLayerMockRecorder) CopyObject(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyObject", reflect.TypeOf((*MockObjectLayer)(nil).CopyObject), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
// CopyObjectPart mocks base method
|
||||
func (m *MockObjectLayer) CopyObjectPart(arg0 context.Context, arg1, arg2, arg3, arg4, arg5 string, arg6 int, arg7, arg8 int64, arg9 cmd.ObjectInfo) (cmd.PartInfo, error) {
|
||||
ret := m.ctrl.Call(m, "CopyObjectPart", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
|
||||
ret0, _ := ret[0].(cmd.PartInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// CopyObjectPart indicates an expected call of CopyObjectPart
|
||||
func (mr *MockObjectLayerMockRecorder) CopyObjectPart(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyObjectPart", reflect.TypeOf((*MockObjectLayer)(nil).CopyObjectPart), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
|
||||
}
|
||||
|
||||
// DeleteBucket mocks base method
|
||||
func (m *MockObjectLayer) DeleteBucket(arg0 context.Context, arg1 string) error {
|
||||
ret := m.ctrl.Call(m, "DeleteBucket", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteBucket indicates an expected call of DeleteBucket
|
||||
func (mr *MockObjectLayerMockRecorder) DeleteBucket(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBucket", reflect.TypeOf((*MockObjectLayer)(nil).DeleteBucket), arg0, arg1)
|
||||
}
|
||||
|
||||
// DeleteBucketPolicy mocks base method
|
||||
func (m *MockObjectLayer) DeleteBucketPolicy(arg0 context.Context, arg1 string) error {
|
||||
ret := m.ctrl.Call(m, "DeleteBucketPolicy", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteBucketPolicy indicates an expected call of DeleteBucketPolicy
|
||||
func (mr *MockObjectLayerMockRecorder) DeleteBucketPolicy(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBucketPolicy", reflect.TypeOf((*MockObjectLayer)(nil).DeleteBucketPolicy), arg0, arg1)
|
||||
}
|
||||
|
||||
// DeleteObject mocks base method
|
||||
func (m *MockObjectLayer) DeleteObject(arg0 context.Context, arg1, arg2 string) error {
|
||||
ret := m.ctrl.Call(m, "DeleteObject", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteObject indicates an expected call of DeleteObject
|
||||
func (mr *MockObjectLayerMockRecorder) DeleteObject(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteObject", reflect.TypeOf((*MockObjectLayer)(nil).DeleteObject), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// GetBucketInfo mocks base method
|
||||
func (m *MockObjectLayer) GetBucketInfo(arg0 context.Context, arg1 string) (cmd.BucketInfo, error) {
|
||||
ret := m.ctrl.Call(m, "GetBucketInfo", arg0, arg1)
|
||||
ret0, _ := ret[0].(cmd.BucketInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBucketInfo indicates an expected call of GetBucketInfo
|
||||
func (mr *MockObjectLayerMockRecorder) GetBucketInfo(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBucketInfo", reflect.TypeOf((*MockObjectLayer)(nil).GetBucketInfo), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetBucketPolicy mocks base method
|
||||
func (m *MockObjectLayer) GetBucketPolicy(arg0 context.Context, arg1 string) (*policy.Policy, error) {
|
||||
ret := m.ctrl.Call(m, "GetBucketPolicy", arg0, arg1)
|
||||
ret0, _ := ret[0].(*policy.Policy)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetBucketPolicy indicates an expected call of GetBucketPolicy
|
||||
func (mr *MockObjectLayerMockRecorder) GetBucketPolicy(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBucketPolicy", reflect.TypeOf((*MockObjectLayer)(nil).GetBucketPolicy), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetObject mocks base method
|
||||
func (m *MockObjectLayer) GetObject(arg0 context.Context, arg1, arg2 string, arg3, arg4 int64, arg5 io.Writer, arg6 string) error {
|
||||
ret := m.ctrl.Call(m, "GetObject", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetObject indicates an expected call of GetObject
|
||||
func (mr *MockObjectLayerMockRecorder) GetObject(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObject", reflect.TypeOf((*MockObjectLayer)(nil).GetObject), arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
}
|
||||
|
||||
// GetObjectInfo mocks base method
|
||||
func (m *MockObjectLayer) GetObjectInfo(arg0 context.Context, arg1, arg2 string) (cmd.ObjectInfo, error) {
|
||||
ret := m.ctrl.Call(m, "GetObjectInfo", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(cmd.ObjectInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetObjectInfo indicates an expected call of GetObjectInfo
|
||||
func (mr *MockObjectLayerMockRecorder) GetObjectInfo(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectInfo", reflect.TypeOf((*MockObjectLayer)(nil).GetObjectInfo), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// HealBucket mocks base method
|
||||
func (m *MockObjectLayer) HealBucket(arg0 context.Context, arg1 string, arg2 bool) ([]madmin.HealResultItem, error) {
|
||||
ret := m.ctrl.Call(m, "HealBucket", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].([]madmin.HealResultItem)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HealBucket indicates an expected call of HealBucket
|
||||
func (mr *MockObjectLayerMockRecorder) HealBucket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealBucket", reflect.TypeOf((*MockObjectLayer)(nil).HealBucket), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// HealFormat mocks base method
|
||||
func (m *MockObjectLayer) HealFormat(arg0 context.Context, arg1 bool) (madmin.HealResultItem, error) {
|
||||
ret := m.ctrl.Call(m, "HealFormat", arg0, arg1)
|
||||
ret0, _ := ret[0].(madmin.HealResultItem)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HealFormat indicates an expected call of HealFormat
|
||||
func (mr *MockObjectLayerMockRecorder) HealFormat(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealFormat", reflect.TypeOf((*MockObjectLayer)(nil).HealFormat), arg0, arg1)
|
||||
}
|
||||
|
||||
// HealObject mocks base method
|
||||
func (m *MockObjectLayer) HealObject(arg0 context.Context, arg1, arg2 string, arg3 bool) (madmin.HealResultItem, error) {
|
||||
ret := m.ctrl.Call(m, "HealObject", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(madmin.HealResultItem)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HealObject indicates an expected call of HealObject
|
||||
func (mr *MockObjectLayerMockRecorder) HealObject(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HealObject", reflect.TypeOf((*MockObjectLayer)(nil).HealObject), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// IsEncryptionSupported mocks base method
|
||||
func (m *MockObjectLayer) IsEncryptionSupported() bool {
|
||||
ret := m.ctrl.Call(m, "IsEncryptionSupported")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsEncryptionSupported indicates an expected call of IsEncryptionSupported
|
||||
func (mr *MockObjectLayerMockRecorder) IsEncryptionSupported() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsEncryptionSupported", reflect.TypeOf((*MockObjectLayer)(nil).IsEncryptionSupported))
|
||||
}
|
||||
|
||||
// IsNotificationSupported mocks base method
|
||||
func (m *MockObjectLayer) IsNotificationSupported() bool {
|
||||
ret := m.ctrl.Call(m, "IsNotificationSupported")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsNotificationSupported indicates an expected call of IsNotificationSupported
|
||||
func (mr *MockObjectLayerMockRecorder) IsNotificationSupported() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNotificationSupported", reflect.TypeOf((*MockObjectLayer)(nil).IsNotificationSupported))
|
||||
}
|
||||
|
||||
// ListBuckets mocks base method
|
||||
func (m *MockObjectLayer) ListBuckets(arg0 context.Context) ([]cmd.BucketInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListBuckets", arg0)
|
||||
ret0, _ := ret[0].([]cmd.BucketInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListBuckets indicates an expected call of ListBuckets
|
||||
func (mr *MockObjectLayerMockRecorder) ListBuckets(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListBuckets", reflect.TypeOf((*MockObjectLayer)(nil).ListBuckets), arg0)
|
||||
}
|
||||
|
||||
// ListBucketsHeal mocks base method
|
||||
func (m *MockObjectLayer) ListBucketsHeal(arg0 context.Context) ([]cmd.BucketInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListBucketsHeal", arg0)
|
||||
ret0, _ := ret[0].([]cmd.BucketInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListBucketsHeal indicates an expected call of ListBucketsHeal
|
||||
func (mr *MockObjectLayerMockRecorder) ListBucketsHeal(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListBucketsHeal", reflect.TypeOf((*MockObjectLayer)(nil).ListBucketsHeal), arg0)
|
||||
}
|
||||
|
||||
// ListLocks mocks base method
|
||||
func (m *MockObjectLayer) ListLocks(arg0 context.Context, arg1, arg2 string, arg3 time.Duration) ([]cmd.VolumeLockInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListLocks", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].([]cmd.VolumeLockInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListLocks indicates an expected call of ListLocks
|
||||
func (mr *MockObjectLayerMockRecorder) ListLocks(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLocks", reflect.TypeOf((*MockObjectLayer)(nil).ListLocks), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// ListMultipartUploads mocks base method
|
||||
func (m *MockObjectLayer) ListMultipartUploads(arg0 context.Context, arg1, arg2, arg3, arg4, arg5 string, arg6 int) (cmd.ListMultipartsInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListMultipartUploads", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
ret0, _ := ret[0].(cmd.ListMultipartsInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListMultipartUploads indicates an expected call of ListMultipartUploads
|
||||
func (mr *MockObjectLayerMockRecorder) ListMultipartUploads(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListMultipartUploads", reflect.TypeOf((*MockObjectLayer)(nil).ListMultipartUploads), arg0, arg1, arg2, arg3, arg4, arg5, arg6)
|
||||
}
|
||||
|
||||
// ListObjectParts mocks base method
|
||||
func (m *MockObjectLayer) ListObjectParts(arg0 context.Context, arg1, arg2, arg3 string, arg4, arg5 int) (cmd.ListPartsInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListObjectParts", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
ret0, _ := ret[0].(cmd.ListPartsInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListObjectParts indicates an expected call of ListObjectParts
|
||||
func (mr *MockObjectLayerMockRecorder) ListObjectParts(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListObjectParts", reflect.TypeOf((*MockObjectLayer)(nil).ListObjectParts), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
// ListObjects mocks base method
|
||||
func (m *MockObjectLayer) ListObjects(arg0 context.Context, arg1, arg2, arg3, arg4 string, arg5 int) (cmd.ListObjectsInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListObjects", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
ret0, _ := ret[0].(cmd.ListObjectsInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListObjects indicates an expected call of ListObjects
|
||||
func (mr *MockObjectLayerMockRecorder) ListObjects(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListObjects", reflect.TypeOf((*MockObjectLayer)(nil).ListObjects), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
// ListObjectsHeal mocks base method
|
||||
func (m *MockObjectLayer) ListObjectsHeal(arg0 context.Context, arg1, arg2, arg3, arg4 string, arg5 int) (cmd.ListObjectsInfo, error) {
|
||||
ret := m.ctrl.Call(m, "ListObjectsHeal", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
ret0, _ := ret[0].(cmd.ListObjectsInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListObjectsHeal indicates an expected call of ListObjectsHeal
|
||||
func (mr *MockObjectLayerMockRecorder) ListObjectsHeal(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListObjectsHeal", reflect.TypeOf((*MockObjectLayer)(nil).ListObjectsHeal), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
// ListObjectsV2 mocks base method
|
||||
func (m *MockObjectLayer) ListObjectsV2(arg0 context.Context, arg1, arg2, arg3, arg4 string, arg5 int, arg6 bool, arg7 string) (cmd.ListObjectsV2Info, error) {
|
||||
ret := m.ctrl.Call(m, "ListObjectsV2", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
||||
ret0, _ := ret[0].(cmd.ListObjectsV2Info)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListObjectsV2 indicates an expected call of ListObjectsV2
|
||||
func (mr *MockObjectLayerMockRecorder) ListObjectsV2(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListObjectsV2", reflect.TypeOf((*MockObjectLayer)(nil).ListObjectsV2), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
|
||||
}
|
||||
|
||||
// MakeBucketWithLocation mocks base method
|
||||
func (m *MockObjectLayer) MakeBucketWithLocation(arg0 context.Context, arg1, arg2 string) error {
|
||||
ret := m.ctrl.Call(m, "MakeBucketWithLocation", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// MakeBucketWithLocation indicates an expected call of MakeBucketWithLocation
|
||||
func (mr *MockObjectLayerMockRecorder) MakeBucketWithLocation(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MakeBucketWithLocation", reflect.TypeOf((*MockObjectLayer)(nil).MakeBucketWithLocation), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// NewMultipartUpload mocks base method
|
||||
func (m *MockObjectLayer) NewMultipartUpload(arg0 context.Context, arg1, arg2 string, arg3 map[string]string) (string, error) {
|
||||
ret := m.ctrl.Call(m, "NewMultipartUpload", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(string)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// NewMultipartUpload indicates an expected call of NewMultipartUpload
|
||||
func (mr *MockObjectLayerMockRecorder) NewMultipartUpload(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewMultipartUpload", reflect.TypeOf((*MockObjectLayer)(nil).NewMultipartUpload), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// PutObject mocks base method
|
||||
func (m *MockObjectLayer) PutObject(arg0 context.Context, arg1, arg2 string, arg3 *hash.Reader, arg4 map[string]string) (cmd.ObjectInfo, error) {
|
||||
ret := m.ctrl.Call(m, "PutObject", arg0, arg1, arg2, arg3, arg4)
|
||||
ret0, _ := ret[0].(cmd.ObjectInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PutObject indicates an expected call of PutObject
|
||||
func (mr *MockObjectLayerMockRecorder) PutObject(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutObject", reflect.TypeOf((*MockObjectLayer)(nil).PutObject), arg0, arg1, arg2, arg3, arg4)
|
||||
}
|
||||
|
||||
// PutObjectPart mocks base method
|
||||
func (m *MockObjectLayer) PutObjectPart(arg0 context.Context, arg1, arg2, arg3 string, arg4 int, arg5 *hash.Reader) (cmd.PartInfo, error) {
|
||||
ret := m.ctrl.Call(m, "PutObjectPart", arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
ret0, _ := ret[0].(cmd.PartInfo)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// PutObjectPart indicates an expected call of PutObjectPart
|
||||
func (mr *MockObjectLayerMockRecorder) PutObjectPart(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PutObjectPart", reflect.TypeOf((*MockObjectLayer)(nil).PutObjectPart), arg0, arg1, arg2, arg3, arg4, arg5)
|
||||
}
|
||||
|
||||
// ReloadFormat mocks base method
|
||||
func (m *MockObjectLayer) ReloadFormat(arg0 context.Context, arg1 bool) error {
|
||||
ret := m.ctrl.Call(m, "ReloadFormat", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ReloadFormat indicates an expected call of ReloadFormat
|
||||
func (mr *MockObjectLayerMockRecorder) ReloadFormat(arg0, arg1 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReloadFormat", reflect.TypeOf((*MockObjectLayer)(nil).ReloadFormat), arg0, arg1)
|
||||
}
|
||||
|
||||
// SetBucketPolicy mocks base method
|
||||
func (m *MockObjectLayer) SetBucketPolicy(arg0 context.Context, arg1 string, arg2 *policy.Policy) error {
|
||||
ret := m.ctrl.Call(m, "SetBucketPolicy", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// SetBucketPolicy indicates an expected call of SetBucketPolicy
|
||||
func (mr *MockObjectLayerMockRecorder) SetBucketPolicy(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBucketPolicy", reflect.TypeOf((*MockObjectLayer)(nil).SetBucketPolicy), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// Shutdown mocks base method
|
||||
func (m *MockObjectLayer) Shutdown(arg0 context.Context) error {
|
||||
ret := m.ctrl.Call(m, "Shutdown", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Shutdown indicates an expected call of Shutdown
|
||||
func (mr *MockObjectLayerMockRecorder) Shutdown(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Shutdown", reflect.TypeOf((*MockObjectLayer)(nil).Shutdown), arg0)
|
||||
}
|
||||
|
||||
// StorageInfo mocks base method
|
||||
func (m *MockObjectLayer) StorageInfo(arg0 context.Context) cmd.StorageInfo {
|
||||
ret := m.ctrl.Call(m, "StorageInfo", arg0)
|
||||
ret0, _ := ret[0].(cmd.StorageInfo)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// StorageInfo indicates an expected call of StorageInfo
|
||||
func (mr *MockObjectLayerMockRecorder) StorageInfo(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StorageInfo", reflect.TypeOf((*MockObjectLayer)(nil).StorageInfo), arg0)
|
||||
}
|
Loading…
Reference in New Issue
Block a user