mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
Fixed lint issues with files (#3234)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -39,7 +39,7 @@ func TestArnsList(t *testing.T) {
|
||||
assert := asrt.New(t)
|
||||
adminClient := AdminClientMock{}
|
||||
// Test-1 : getArns() returns proper arn list
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{
|
||||
SQSARN: []string{"uno"},
|
||||
}, nil
|
||||
@@ -54,7 +54,7 @@ func TestArnsList(t *testing.T) {
|
||||
assert.Nil(err, "Error should have been nil")
|
||||
|
||||
// Test-2 : getArns(ctx) fails for whatever reason
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{}, errors.New("some reason")
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,6 @@ func resetConfigResponse(session *models.Principal, params cfgApi.ResetConfigPar
|
||||
adminClient := AdminClient{Client: mAdmin}
|
||||
|
||||
err = resetConfig(ctx, adminClient, ¶ms.Name)
|
||||
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestListConfig(t *testing.T) {
|
||||
}
|
||||
expectedKeysDesc := mockConfigList.KeysHelp
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return mockConfigList, nil
|
||||
}
|
||||
configList, err := listConfig(adminClient)
|
||||
@@ -80,7 +80,7 @@ func TestListConfig(t *testing.T) {
|
||||
|
||||
// Test-2 : listConfig() Return error and see that the error is handled correctly and returned
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("error")
|
||||
}
|
||||
_, err = listConfig(adminClient)
|
||||
@@ -94,7 +94,7 @@ func TestSetConfig(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
function := "setConfig()"
|
||||
// mock function response from setConfig()
|
||||
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
|
||||
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
}
|
||||
configName := "notify_postgres"
|
||||
@@ -119,7 +119,7 @@ func TestSetConfig(t *testing.T) {
|
||||
assert.Equal(restart, false)
|
||||
|
||||
// Test-2 : setConfig() returns error, handle properly
|
||||
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
|
||||
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
|
||||
return false, errors.New("error")
|
||||
}
|
||||
restart, err = setConfig(ctx, adminClient, &configName, kvs)
|
||||
@@ -129,7 +129,7 @@ func TestSetConfig(t *testing.T) {
|
||||
assert.Equal(restart, false)
|
||||
|
||||
// Test-4 : setConfig() set config, need restart
|
||||
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
|
||||
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
restart, err = setConfig(ctx, adminClient, &configName, kvs)
|
||||
@@ -144,7 +144,7 @@ func TestDelConfig(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
function := "resetConfig()"
|
||||
// mock function response from setConfig()
|
||||
minioDelConfigKVMock = func(name string) (err error) {
|
||||
minioDelConfigKVMock = func(_ string) (err error) {
|
||||
return nil
|
||||
}
|
||||
configName := "region"
|
||||
@@ -158,7 +158,7 @@ func TestDelConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2 : resetConfig() returns error, handle properly
|
||||
minioDelConfigKVMock = func(name string) (err error) {
|
||||
minioDelConfigKVMock = func(_ string) (err error) {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func Test_buildConfig(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := buildConfig(tt.args.configName, tt.args.kvs); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("buildConfig() = %s, want %s", *got, *tt.want)
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func Test_setConfigWithARN(t *testing.T) {
|
||||
},
|
||||
arn: "1",
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -280,7 +280,7 @@ func Test_setConfigWithARN(t *testing.T) {
|
||||
},
|
||||
arn: "1",
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return true, nil
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -300,7 +300,7 @@ func Test_setConfigWithARN(t *testing.T) {
|
||||
},
|
||||
arn: "",
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -320,7 +320,7 @@ func Test_setConfigWithARN(t *testing.T) {
|
||||
},
|
||||
arn: "",
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, errors.New("error")
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -328,7 +328,7 @@ func Test_setConfigWithARN(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// mock function response from setConfig()
|
||||
minioSetConfigKVMock = tt.mockSetConfig
|
||||
restart, err := setConfigWithARNAccountID(tt.args.ctx, tt.args.client, tt.args.configName, tt.args.kvs, tt.args.arn)
|
||||
@@ -361,7 +361,7 @@ func Test_getConfig(t *testing.T) {
|
||||
},
|
||||
mock: func() {
|
||||
// mock function response from getConfig()
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
return []byte(`notify_postgres:_ connection_string="host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable" table=bucketevents`), nil
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func Test_getConfig(t *testing.T) {
|
||||
KeysHelp: configListMock,
|
||||
}
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return mockConfigList, nil
|
||||
}
|
||||
},
|
||||
@@ -435,7 +435,7 @@ func Test_getConfig(t *testing.T) {
|
||||
},
|
||||
mock: func() {
|
||||
// mock function response from getConfig()
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
return []byte(`notify_postgres:_`), nil
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ func Test_getConfig(t *testing.T) {
|
||||
KeysHelp: configListMock,
|
||||
}
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return mockConfigList, nil
|
||||
}
|
||||
},
|
||||
@@ -496,7 +496,7 @@ func Test_getConfig(t *testing.T) {
|
||||
},
|
||||
mock: func() {
|
||||
// mock function response from getConfig()
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
x := make(map[string]string)
|
||||
x["x"] = "x"
|
||||
j, _ := json.Marshal(x)
|
||||
@@ -545,7 +545,7 @@ func Test_getConfig(t *testing.T) {
|
||||
KeysHelp: configListMock,
|
||||
}
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return mockConfigList, nil
|
||||
}
|
||||
},
|
||||
@@ -560,13 +560,13 @@ func Test_getConfig(t *testing.T) {
|
||||
},
|
||||
mock: func() {
|
||||
// mock function response from getConfig()
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
return nil, errors.New("invalid config")
|
||||
}
|
||||
|
||||
mockConfigList := madmin.Help{}
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return mockConfigList, nil
|
||||
}
|
||||
},
|
||||
@@ -581,11 +581,11 @@ func Test_getConfig(t *testing.T) {
|
||||
},
|
||||
mock: func() {
|
||||
// mock function response from getConfig()
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
return nil, errors.New("invalid config")
|
||||
}
|
||||
// mock function response from listConfig()
|
||||
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("no help")
|
||||
}
|
||||
},
|
||||
@@ -595,7 +595,7 @@ func Test_getConfig(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt.mock()
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, err := getConfig(context.Background(), tt.args.client, tt.args.name)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("getConfig() error = %v, wantErr %v", err, tt.wantErr)
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestAdminConsoleLog(t *testing.T) {
|
||||
|
||||
// Test-1: Serve Console with no errors until Console finishes sending
|
||||
// define mock function behavior for minio server Console
|
||||
minioGetLogsMock = func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo {
|
||||
minioGetLogsMock = func(_ context.Context, _ string, _ int, _ string) <-chan madmin.LogInfo {
|
||||
ch := make(chan madmin.LogInfo)
|
||||
// Only success, start a routine to start reading line by line.
|
||||
go func(ch chan<- madmin.LogInfo) {
|
||||
@@ -58,7 +58,7 @@ func TestAdminConsoleLog(t *testing.T) {
|
||||
}
|
||||
writesCount := 1
|
||||
// mock connection WriteMessage() no error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, data []byte) error {
|
||||
// emulate that receiver gets the message written
|
||||
var t madmin.LogInfo
|
||||
_ = json.Unmarshal(data, &t)
|
||||
@@ -82,7 +82,7 @@ func TestAdminConsoleLog(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: if error happens while writing, return error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return fmt.Errorf("error on write")
|
||||
}
|
||||
if err := startConsoleLog(ctx, mockWSConn, adminClient, LogRequest{node: "", logType: "all"}); assert.Error(err) {
|
||||
@@ -91,7 +91,7 @@ func TestAdminConsoleLog(t *testing.T) {
|
||||
|
||||
// Test-3: error happens on GetLogs Minio, Console should stop
|
||||
// and error shall be returned.
|
||||
minioGetLogsMock = func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo {
|
||||
minioGetLogsMock = func(_ context.Context, _ string, _ int, _ string) <-chan madmin.LogInfo {
|
||||
ch := make(chan madmin.LogInfo)
|
||||
// Only success, start a routine to start reading line by line.
|
||||
go func(ch chan<- madmin.LogInfo) {
|
||||
@@ -108,7 +108,7 @@ func TestAdminConsoleLog(t *testing.T) {
|
||||
}(ch)
|
||||
return ch
|
||||
}
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return nil
|
||||
}
|
||||
if err := startConsoleLog(ctx, mockWSConn, adminClient, LogRequest{node: "", logType: "all"}); assert.Error(err) {
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestGroupInfo(t *testing.T) {
|
||||
Status: "enabled",
|
||||
}
|
||||
// mock function response from updateGroupMembers()
|
||||
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
|
||||
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
function := "groupInfo()"
|
||||
@@ -144,7 +144,7 @@ func TestGroupInfo(t *testing.T) {
|
||||
assert.Equal("enabled", info.Status)
|
||||
|
||||
// Test-2 : groupInfo() Return error and see that the error is handled correctly and returned
|
||||
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
|
||||
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
|
||||
return nil, errors.New("error")
|
||||
}
|
||||
_, err = groupInfo(ctx, adminClient, groupName)
|
||||
@@ -226,7 +226,7 @@ func TestUpdateGroup(t *testing.T) {
|
||||
// the function twice but the second time returned an error
|
||||
is2ndRunGroupInfo := false
|
||||
// mock function response from updateGroupMembers()
|
||||
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
|
||||
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
|
||||
if is2ndRunGroupInfo {
|
||||
return mockResponseAfterUpdate, nil
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func TestUpdateGroup(t *testing.T) {
|
||||
minioUpdateGroupMembersMock = func(madmin.GroupAddRemove) error {
|
||||
return nil
|
||||
}
|
||||
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
|
||||
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
|
||||
return nil
|
||||
}
|
||||
groupUpdated, err := groupUpdate(ctx, adminClient, groupName, expectedGroupUpdate)
|
||||
@@ -258,7 +258,7 @@ func TestSetGroupStatus(t *testing.T) {
|
||||
defer cancel()
|
||||
// Test-1: setGroupStatus() update valid disabled status
|
||||
expectedStatus := "disabled"
|
||||
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
|
||||
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); err != nil {
|
||||
@@ -266,7 +266,7 @@ func TestSetGroupStatus(t *testing.T) {
|
||||
}
|
||||
// Test-2: setGroupStatus() update valid enabled status
|
||||
expectedStatus = "enabled"
|
||||
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
|
||||
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); err != nil {
|
||||
@@ -274,7 +274,7 @@ func TestSetGroupStatus(t *testing.T) {
|
||||
}
|
||||
// Test-3: setGroupStatus() update invalid status, should send error
|
||||
expectedStatus = "invalid"
|
||||
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
|
||||
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); assert.Error(err) {
|
||||
@@ -282,7 +282,7 @@ func TestSetGroupStatus(t *testing.T) {
|
||||
}
|
||||
// Test-4: setGroupStatus() handler error correctly
|
||||
expectedStatus = "enabled"
|
||||
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
|
||||
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); assert.Error(err) {
|
||||
|
||||
@@ -51,7 +51,7 @@ func Test_serverHealthInfo(t *testing.T) {
|
||||
args: args{
|
||||
deadline: deadlineDuration,
|
||||
mockMessages: []madmin.HealthInfo{{}, {}},
|
||||
wsWriteMock: func(messageType int, data []byte) error {
|
||||
wsWriteMock: func(_ int, data []byte) error {
|
||||
// mock connection WriteMessage() no error
|
||||
// emulate that receiver gets the message written
|
||||
var t madmin.HealthInfo
|
||||
@@ -67,7 +67,7 @@ func Test_serverHealthInfo(t *testing.T) {
|
||||
args: args{
|
||||
deadline: deadlineDuration,
|
||||
mockMessages: []madmin.HealthInfo{{}},
|
||||
wsWriteMock: func(messageType int, data []byte) error {
|
||||
wsWriteMock: func(_ int, data []byte) error {
|
||||
// mock connection WriteMessage() no error
|
||||
// emulate that receiver gets the message written
|
||||
var t madmin.HealthInfo
|
||||
@@ -83,7 +83,7 @@ func Test_serverHealthInfo(t *testing.T) {
|
||||
args: args{
|
||||
deadline: deadlineDuration,
|
||||
mockMessages: []madmin.HealthInfo{{}},
|
||||
wsWriteMock: func(messageType int, data []byte) error {
|
||||
wsWriteMock: func(_ int, data []byte) error {
|
||||
// mock connection WriteMessage() no error
|
||||
// emulate that receiver gets the message written
|
||||
var t madmin.HealthInfo
|
||||
@@ -102,7 +102,7 @@ func Test_serverHealthInfo(t *testing.T) {
|
||||
Error: "error on healthInfo",
|
||||
},
|
||||
},
|
||||
wsWriteMock: func(messageType int, data []byte) error {
|
||||
wsWriteMock: func(_ int, data []byte) error {
|
||||
// mock connection WriteMessage() no error
|
||||
// emulate that receiver gets the message written
|
||||
var t madmin.HealthInfo
|
||||
@@ -115,12 +115,12 @@ func Test_serverHealthInfo(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
// make testReceiver channel
|
||||
testReceiver = make(chan madmin.HealthInfo, len(tt.args.mockMessages))
|
||||
// mock function same for all tests, changes mockMessages
|
||||
minioServerHealthInfoMock = func(ctx context.Context, healthDataTypes []madmin.HealthDataType,
|
||||
deadline time.Duration,
|
||||
minioServerHealthInfoMock = func(_ context.Context, _ []madmin.HealthDataType,
|
||||
_ time.Duration,
|
||||
) (interface{}, string, error) {
|
||||
info := tt.args.mockMessages[0]
|
||||
return info, madmin.HealthInfoVersion, nil
|
||||
|
||||
@@ -46,7 +46,7 @@ type IDPTestSuite struct {
|
||||
func (suite *IDPTestSuite) SetupSuite() {
|
||||
suite.assert = assert.New(suite.T())
|
||||
suite.adminClient = AdminClientMock{}
|
||||
minioServiceRestartMock = func(ctx context.Context) error {
|
||||
minioServiceRestartMock = func(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ func TestGetEntitiesResult(t *testing.T) {
|
||||
GroupMappings: groupsMap,
|
||||
UserMappings: usersMap,
|
||||
}
|
||||
minioGetLDAPPolicyEntitiesMock = func(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
|
||||
minioGetLDAPPolicyEntitiesMock = func(_ context.Context, _ madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ func TestGetEntitiesResult(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: getEntitiesResult error is returned from getLDAPPolicyEntities()
|
||||
minioGetLDAPPolicyEntitiesMock = func(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
|
||||
minioGetLDAPPolicyEntitiesMock = func(_ context.Context, _ madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
|
||||
return madmin.PolicyEntitiesResult{}, errors.New("error")
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func registerAdminInfoHandlers(api *operations.ConsoleAPI) {
|
||||
return systemApi.NewAdminInfoOK().WithPayload(infoResp)
|
||||
})
|
||||
// return single widget results
|
||||
api.SystemDashboardWidgetDetailsHandler = systemApi.DashboardWidgetDetailsHandlerFunc(func(params systemApi.DashboardWidgetDetailsParams, session *models.Principal) middleware.Responder {
|
||||
api.SystemDashboardWidgetDetailsHandler = systemApi.DashboardWidgetDetailsHandlerFunc(func(params systemApi.DashboardWidgetDetailsParams, _ *models.Principal) middleware.Responder {
|
||||
infoResp, err := getAdminInfoWidgetResponse(params)
|
||||
if err != nil {
|
||||
return systemApi.NewDashboardWidgetDetailsDefault(err.Code).WithPayload(err.APIError)
|
||||
|
||||
@@ -46,7 +46,7 @@ type AdminInfoTestSuite struct {
|
||||
func (suite *AdminInfoTestSuite) SetupSuite() {
|
||||
suite.assert = assert.New(suite.T())
|
||||
suite.adminClient = AdminClientMock{}
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{
|
||||
Servers: []madmin.ServerProperties{{
|
||||
Disks: []madmin.Disk{{}},
|
||||
|
||||
@@ -61,7 +61,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -94,7 +94,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, errors.New("error")
|
||||
},
|
||||
want: nil,
|
||||
@@ -118,7 +118,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -149,7 +149,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -178,7 +178,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -208,7 +208,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -240,7 +240,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -273,7 +273,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -305,7 +305,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -335,7 +335,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -365,7 +365,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -397,7 +397,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return false, errors.New("invalid config")
|
||||
},
|
||||
want: nil,
|
||||
@@ -421,7 +421,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
mockSetConfig: func(kv string) (restart bool, err error) {
|
||||
mockSetConfig: func(_ string) (restart bool, err error) {
|
||||
return true, nil
|
||||
},
|
||||
want: &models.SetNotificationEndpointResponse{
|
||||
@@ -438,7 +438,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// mock function response from setConfig()
|
||||
minioSetConfigKVMock = tt.mockSetConfig
|
||||
got, err := addNotificationEndpoint(tt.args.ctx, tt.args.client, tt.args.params)
|
||||
|
||||
@@ -97,11 +97,11 @@ func TestWSRewindObjects(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
mcListMock = func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
|
||||
mcListMock = func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
|
||||
ch := make(chan *mc.ClientContent)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
@@ -206,11 +206,11 @@ func TestWSListObjects(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
minioListObjectsMock = func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
minioListObjectsMock = func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
ch := make(chan minio.ObjectInfo)
|
||||
go func() {
|
||||
defer close(ch)
|
||||
|
||||
@@ -83,7 +83,7 @@ func TestRemovePolicy(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
// Test-1 : removePolicy() remove an existing policy
|
||||
policyToRemove := "console-policy"
|
||||
minioRemovePolicyMock = func(name string) error {
|
||||
minioRemovePolicyMock = func(_ string) error {
|
||||
return nil
|
||||
}
|
||||
function := "removePolicy()"
|
||||
@@ -91,7 +91,7 @@ func TestRemovePolicy(t *testing.T) {
|
||||
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
|
||||
}
|
||||
// Test-2 : removePolicy() Return error and see that the error is handled correctly and returned
|
||||
minioRemovePolicyMock = func(name string) error {
|
||||
minioRemovePolicyMock = func(_ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := removePolicy(ctx, adminClient, policyToRemove); funcAssert.Error(err) {
|
||||
@@ -106,10 +106,10 @@ func TestAddPolicy(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
policyName := "new-policy"
|
||||
policyDefinition := "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetBucketLocation\",\"s3:GetObject\",\"s3:ListAllMyBuckets\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}"
|
||||
minioAddPolicyMock = func(name string, policy *iampolicy.Policy) error {
|
||||
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
|
||||
return nil
|
||||
}
|
||||
minioGetPolicyMock = func(name string) (*iampolicy.Policy, error) {
|
||||
minioGetPolicyMock = func(_ string) (*iampolicy.Policy, error) {
|
||||
policy := "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetBucketLocation\",\"s3:GetObject\",\"s3:ListAllMyBuckets\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}"
|
||||
iamp, err := iampolicy.ParseConfig(bytes.NewReader([]byte(policy)))
|
||||
if err != nil {
|
||||
@@ -138,17 +138,17 @@ func TestAddPolicy(t *testing.T) {
|
||||
funcAssert.Equal(expectedPolicy, actualPolicy)
|
||||
}
|
||||
// Test-2 : addPolicy() got an error while adding policy
|
||||
minioAddPolicyMock = func(name string, policy *iampolicy.Policy) error {
|
||||
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if _, err := addPolicy(ctx, adminClient, policyName, policyDefinition); funcAssert.Error(err) {
|
||||
funcAssert.Equal("error", err.Error())
|
||||
}
|
||||
// Test-3 : addPolicy() got an error while retrieving policy
|
||||
minioAddPolicyMock = func(name string, policy *iampolicy.Policy) error {
|
||||
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
|
||||
return nil
|
||||
}
|
||||
minioGetPolicyMock = func(name string) (*iampolicy.Policy, error) {
|
||||
minioGetPolicyMock = func(_ string) (*iampolicy.Policy, error) {
|
||||
return nil, errors.New("error")
|
||||
}
|
||||
if _, err := addPolicy(ctx, adminClient, policyName, policyDefinition); funcAssert.Error(err) {
|
||||
@@ -164,7 +164,7 @@ func TestSetPolicy(t *testing.T) {
|
||||
policyName := "readOnly"
|
||||
entityName := "alevsk"
|
||||
entityObject := models.PolicyEntityUser
|
||||
minioSetPolicyMock = func(policyName, entityName string, isGroup bool) error {
|
||||
minioSetPolicyMock = func(_, _ string, _ bool) error {
|
||||
return nil
|
||||
}
|
||||
// Test-1 : SetPolicy() set policy to user
|
||||
@@ -181,7 +181,7 @@ func TestSetPolicy(t *testing.T) {
|
||||
}
|
||||
// Test-3 : SetPolicy() set policy to user and get error
|
||||
entityObject = models.PolicyEntityUser
|
||||
minioSetPolicyMock = func(policyName, entityName string, isGroup bool) error {
|
||||
minioSetPolicyMock = func(_, _ string, _ bool) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := SetPolicy(ctx, adminClient, policyName, entityName, entityObject); funcAssert.Error(err) {
|
||||
@@ -189,7 +189,7 @@ func TestSetPolicy(t *testing.T) {
|
||||
}
|
||||
// Test-4 : SetPolicy() set policy to group and get error
|
||||
entityObject = models.PolicyEntityGroup
|
||||
minioSetPolicyMock = func(policyName, entityName string, isGroup bool) error {
|
||||
minioSetPolicyMock = func(_, _ string, _ bool) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := SetPolicy(ctx, adminClient, policyName, entityName, entityObject); funcAssert.Error(err) {
|
||||
@@ -219,7 +219,7 @@ func Test_SetPolicyMultiple(t *testing.T) {
|
||||
policyName: "readonly",
|
||||
users: []models.IamEntity{"user1", "user2"},
|
||||
groups: []models.IamEntity{"group1", "group2"},
|
||||
setPolicyFunc: func(policyName, entityName string, isGroup bool) error {
|
||||
setPolicyFunc: func(_, _ string, _ bool) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -231,7 +231,7 @@ func Test_SetPolicyMultiple(t *testing.T) {
|
||||
policyName: "readonly",
|
||||
users: []models.IamEntity{"user1", "user2"},
|
||||
groups: []models.IamEntity{"group1", "group2"},
|
||||
setPolicyFunc: func(policyName, entityName string, isGroup bool) error {
|
||||
setPolicyFunc: func(_, _ string, _ bool) error {
|
||||
return errors.New("error set")
|
||||
},
|
||||
},
|
||||
@@ -244,7 +244,7 @@ func Test_SetPolicyMultiple(t *testing.T) {
|
||||
policyName: "readonly",
|
||||
users: []models.IamEntity{},
|
||||
groups: []models.IamEntity{},
|
||||
setPolicyFunc: func(policyName, entityName string, isGroup bool) error {
|
||||
setPolicyFunc: func(_, _ string, _ bool) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -252,7 +252,7 @@ func Test_SetPolicyMultiple(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioSetPolicyMock = tt.args.setPolicyFunc
|
||||
got := setPolicyMultipleEntities(ctx, adminClient, tt.args.policyName, tt.args.users, tt.args.groups)
|
||||
if !reflect.DeepEqual(got, tt.errorExpected) {
|
||||
@@ -373,7 +373,7 @@ func Test_policyMatchesBucket(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := policyMatchesBucket(tt.args.ctx, tt.args.policy, tt.args.bucket); got != tt.want {
|
||||
t.Errorf("policyMatchesBucket() = %v, want %v", got, tt.want)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
|
||||
// Test-1 : startProfiling() Get response from MinIO server with one profiling object without errors
|
||||
// mock function response from startProfiling()
|
||||
minioStartProfiling = func(profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
return []madmin.StartProfilingResult{
|
||||
{
|
||||
NodeName: "http://127.0.0.1:9000/",
|
||||
@@ -71,7 +71,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
return &ClosingBuffer{bytes.NewBufferString("In memory string eaeae")}, nil
|
||||
}
|
||||
// mock function response from mockConn.writeMessage()
|
||||
connWriteMessageMock = func(messageType int, p []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return nil
|
||||
}
|
||||
err := startProfiling(ctx, mockWSConn, adminClient, testOptions)
|
||||
@@ -82,7 +82,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
|
||||
// Test-2 : startProfiling() Correctly handles errors returned by MinIO
|
||||
// mock function response from startProfiling()
|
||||
minioStartProfiling = func(profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
|
||||
return nil, errors.New("error")
|
||||
}
|
||||
err = startProfiling(ctx, mockWSConn, adminClient, testOptions)
|
||||
|
||||
@@ -90,7 +90,7 @@ func registerAdminBucketRemoteHandlers(api *operations.ConsoleAPI) {
|
||||
})
|
||||
|
||||
// list external buckets
|
||||
api.BucketListExternalBucketsHandler = bucketApi.ListExternalBucketsHandlerFunc(func(params bucketApi.ListExternalBucketsParams, session *models.Principal) middleware.Responder {
|
||||
api.BucketListExternalBucketsHandler = bucketApi.ListExternalBucketsHandlerFunc(func(params bucketApi.ListExternalBucketsParams, _ *models.Principal) middleware.Responder {
|
||||
response, err := listExternalBucketsResponse(params)
|
||||
if err != nil {
|
||||
return bucketApi.NewListExternalBucketsDefault(err.Code).WithPayload(err.APIError)
|
||||
@@ -796,7 +796,6 @@ func updateBucketReplicationResponse(session *models.Principal, params bucketApi
|
||||
params.Body.Tags,
|
||||
params.Body.Priority,
|
||||
params.Body.StorageClass)
|
||||
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (suite *RemoteBucketsTestSuite) initListExternalBucketsRequest() (params bu
|
||||
|
||||
func (suite *RemoteBucketsTestSuite) TestListExternalBucketsWithError() {
|
||||
ctx := context.Background()
|
||||
minioAccountInfoMock = func(ctx context.Context) (madmin.AccountInfo, error) {
|
||||
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
|
||||
return madmin.AccountInfo{}, errors.New("error")
|
||||
}
|
||||
res, err := listExternalBuckets(ctx, &suite.adminClient)
|
||||
@@ -309,7 +309,7 @@ func (suite *RemoteBucketsTestSuite) TestListExternalBucketsWithError() {
|
||||
|
||||
func (suite *RemoteBucketsTestSuite) TestListExternalBucketsWithoutError() {
|
||||
ctx := context.Background()
|
||||
minioAccountInfoMock = func(ctx context.Context) (madmin.AccountInfo, error) {
|
||||
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
|
||||
return madmin.AccountInfo{
|
||||
Buckets: []madmin.BucketAccessInfo{},
|
||||
}, nil
|
||||
|
||||
@@ -32,10 +32,10 @@ func TestServiceRestart(t *testing.T) {
|
||||
function := "serviceRestart()"
|
||||
// Test-1 : serviceRestart() restart services no errors
|
||||
// mock function response from listGroups()
|
||||
minioServiceRestartMock = func(ctx context.Context) error {
|
||||
minioServiceRestartMock = func(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{}, nil
|
||||
}
|
||||
if err := serviceRestart(ctx, adminClient); err != nil {
|
||||
@@ -44,10 +44,10 @@ func TestServiceRestart(t *testing.T) {
|
||||
|
||||
// Test-2 : serviceRestart() returns errors on client.serviceRestart call
|
||||
// and see that the errors is handled correctly and returned
|
||||
minioServiceRestartMock = func(ctx context.Context) error {
|
||||
minioServiceRestartMock = func(_ context.Context) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{}, nil
|
||||
}
|
||||
if err := serviceRestart(ctx, adminClient); assert.Error(err) {
|
||||
@@ -56,10 +56,10 @@ func TestServiceRestart(t *testing.T) {
|
||||
|
||||
// Test-3 : serviceRestart() returns errors on client.serverInfo() call
|
||||
// and see that the errors is handled correctly and returned
|
||||
minioServiceRestartMock = func(ctx context.Context) error {
|
||||
minioServiceRestartMock = func(_ context.Context) error {
|
||||
return nil
|
||||
}
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{}, errors.New("error on server info")
|
||||
}
|
||||
if err := serviceRestart(ctx, adminClient); assert.Error(err) {
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestGetSiteReplicationInfo(t *testing.T) {
|
||||
ServiceAccountAccessKey: "test-key",
|
||||
}
|
||||
|
||||
getSiteReplicationInfo = func(ctx context.Context) (info *madmin.SiteReplicationInfo, err error) {
|
||||
getSiteReplicationInfo = func(_ context.Context) (info *madmin.SiteReplicationInfo, err error) {
|
||||
return &retValueMock, nil
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestAddSiteReplicationInfo(t *testing.T) {
|
||||
InitialSyncErrorMessage: "",
|
||||
}
|
||||
|
||||
addSiteReplicationInfo = func(ctx context.Context, sites []madmin.PeerSite) (res *madmin.ReplicateAddStatus, err error) {
|
||||
addSiteReplicationInfo = func(_ context.Context, _ []madmin.PeerSite) (res *madmin.ReplicateAddStatus, err error) {
|
||||
return retValueMock, nil
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ func TestEditSiteReplicationInfo(t *testing.T) {
|
||||
ErrDetail: "",
|
||||
}
|
||||
|
||||
editSiteReplicationInfo = func(ctx context.Context, site madmin.PeerInfo) (res *madmin.ReplicateEditStatus, err error) {
|
||||
editSiteReplicationInfo = func(_ context.Context, _ madmin.PeerInfo) (res *madmin.ReplicateEditStatus, err error) {
|
||||
return retValueMock, nil
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ func TestDeleteSiteReplicationInfo(t *testing.T) {
|
||||
ErrDetail: "",
|
||||
}
|
||||
|
||||
deleteSiteReplicationInfoMock = func(ctx context.Context, removeReq madmin.SRRemoveReq) (res *madmin.ReplicateRemoveStatus, err error) {
|
||||
deleteSiteReplicationInfoMock = func(_ context.Context, _ madmin.SRRemoveReq) (res *madmin.ReplicateRemoveStatus, err error) {
|
||||
return retValueMock, nil
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ func TestSiteReplicationStatus(t *testing.T) {
|
||||
GroupStats: nil,
|
||||
}
|
||||
|
||||
getSiteReplicationStatus = func(ctx context.Context, params madmin.SRStatusOptions) (info *madmin.SRStatusInfo, err error) {
|
||||
getSiteReplicationStatus = func(_ context.Context, _ madmin.SRStatusOptions) (info *madmin.SRStatusInfo, err error) {
|
||||
return &retValueMock, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ type AdminSubnetTestSuite struct {
|
||||
func (suite *AdminSubnetTestSuite) SetupSuite() {
|
||||
suite.assert = assert.New(suite.T())
|
||||
suite.adminClient = AdminClientMock{}
|
||||
minioGetConfigKVMock = func(key string) ([]byte, error) {
|
||||
minioGetConfigKVMock = func(_ string) ([]byte, error) {
|
||||
return []byte("subnet license=mock api_key=mock proxy=http://mock.com"), nil
|
||||
}
|
||||
MinioServerInfoMock = func(ctx context.Context) (madmin.InfoMessage, error) {
|
||||
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
|
||||
return madmin.InfoMessage{Servers: []madmin.ServerProperties{{}}}, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ func TestGetTiers(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioListTiersMock = func(ctx context.Context) ([]*madmin.TierConfig, error) {
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMock, nil
|
||||
}
|
||||
|
||||
minioTierStatsMock = func(ctx context.Context) ([]madmin.TierInfo, error) {
|
||||
minioTierStatsMock = func(_ context.Context) ([]madmin.TierInfo, error) {
|
||||
return returnStatsMock, nil
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func TestGetTiers(t *testing.T) {
|
||||
// Test-2 : getBucketLifecycle() list is empty
|
||||
returnListMockT2 := []*madmin.TierConfig{}
|
||||
|
||||
minioListTiersMock = func(ctx context.Context) ([]*madmin.TierConfig, error) {
|
||||
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
|
||||
return returnListMockT2, nil
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func TestAddTier(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1: addTier() add new Tier
|
||||
minioAddTiersMock = func(ctx context.Context, tier *madmin.TierConfig) error {
|
||||
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestAddTier(t *testing.T) {
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2: addTier() error adding Tier
|
||||
minioAddTiersMock = func(ctx context.Context, tier *madmin.TierConfig) error {
|
||||
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
|
||||
return errors.New("error setting new tier")
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ func TestUpdateTierCreds(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
// Test-1: editTierCredentials() update Tier configuration
|
||||
minioEditTiersMock = func(ctx context.Context, tierName string, creds madmin.TierCreds) error {
|
||||
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func TestUpdateTierCreds(t *testing.T) {
|
||||
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
|
||||
|
||||
// Test-2: editTierCredentials() update Tier configuration failure
|
||||
minioEditTiersMock = func(ctx context.Context, tierName string, creds madmin.TierCreds) error {
|
||||
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
|
||||
return errors.New("error message")
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestAdminTrace(t *testing.T) {
|
||||
|
||||
// Test-1: Serve Trace with no errors until trace finishes sending
|
||||
// define mock function behavior for minio server Trace
|
||||
minioServiceTraceMock = func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
|
||||
minioServiceTraceMock = func(_ context.Context, _ int64, _, _, _, _, _ bool) <-chan madmin.ServiceTraceInfo {
|
||||
ch := make(chan madmin.ServiceTraceInfo)
|
||||
// Only success, start a routine to start reading line by line.
|
||||
go func(ch chan<- madmin.ServiceTraceInfo) {
|
||||
@@ -59,7 +59,7 @@ func TestAdminTrace(t *testing.T) {
|
||||
}
|
||||
writesCount := 1
|
||||
// mock connection WriteMessage() no error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, data []byte) error {
|
||||
// emulate that receiver gets the message written
|
||||
var t shortTraceMsg
|
||||
_ = json.Unmarshal(data, &t)
|
||||
@@ -84,7 +84,7 @@ func TestAdminTrace(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: if error happens while writing, return error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return fmt.Errorf("error on write")
|
||||
}
|
||||
if err := startTraceInfo(ctx, mockWSConn, adminClient, TraceRequest{}); assert.Error(err) {
|
||||
@@ -93,7 +93,7 @@ func TestAdminTrace(t *testing.T) {
|
||||
|
||||
// Test-3: error happens on serviceTrace Minio, trace should stop
|
||||
// and error shall be returned.
|
||||
minioServiceTraceMock = func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
|
||||
minioServiceTraceMock = func(_ context.Context, _ int64, _, _, _, _, _ bool) <-chan madmin.ServiceTraceInfo {
|
||||
ch := make(chan madmin.ServiceTraceInfo)
|
||||
// Only success, start a routine to start reading line by line.
|
||||
go func(ch chan<- madmin.ServiceTraceInfo) {
|
||||
@@ -110,7 +110,7 @@ func TestAdminTrace(t *testing.T) {
|
||||
}(ch)
|
||||
return ch
|
||||
}
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return nil
|
||||
}
|
||||
if err := startTraceInfo(ctx, mockWSConn, adminClient, TraceRequest{}); assert.Error(err) {
|
||||
|
||||
@@ -102,15 +102,15 @@ func TestAddUser(t *testing.T) {
|
||||
}
|
||||
|
||||
// mock function response from addUser() return no error
|
||||
minioAddUserMock = func(accessKey, secretKey string) error {
|
||||
minioAddUserMock = func(_, _ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
|
||||
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
|
||||
return *mockResponse, nil
|
||||
}
|
||||
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return nil
|
||||
}
|
||||
// Test-1: Add a user
|
||||
@@ -135,7 +135,7 @@ func TestAddUser(t *testing.T) {
|
||||
accessKey = "AB"
|
||||
secretKey = "ABCDEFGHIABCDEFGHI"
|
||||
// mock function response from addUser() return no error
|
||||
minioAddUserMock = func(accessKey, secretKey string) error {
|
||||
minioAddUserMock = func(_, _ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestAddUser(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-4: add groups function returns an error
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ func TestRemoveUser(t *testing.T) {
|
||||
|
||||
// Test-1: removeUser() delete a user
|
||||
// mock function response from removeUser(accessKey)
|
||||
minioRemoveUserMock = func(accessKey string) error {
|
||||
minioRemoveUserMock = func(_ string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestRemoveUser(t *testing.T) {
|
||||
|
||||
// Test-2: removeUser() make sure errors are handled correctly when error on DeleteUser()
|
||||
// mock function response from removeUser(accessKey)
|
||||
minioRemoveUserMock = func(accessKey string) error {
|
||||
minioRemoveUserMock = func(_ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -220,11 +220,11 @@ func TestUserGroups(t *testing.T) {
|
||||
// Test-1: updateUserGroups() updates the groups for a user
|
||||
// mock function response from updateUserGroups(accessKey, groupsToAssign)
|
||||
|
||||
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
|
||||
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
|
||||
return *mockResponse, nil
|
||||
}
|
||||
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ func TestUserGroups(t *testing.T) {
|
||||
// Test-2: updateUserGroups() make sure errors are handled correctly when error on UpdateGroupMembersMock()
|
||||
// mock function response from removeUser(accessKey)
|
||||
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -244,11 +244,11 @@ func TestUserGroups(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-3: updateUserGroups() make sure we return the correct error when getUserInfo returns error
|
||||
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
|
||||
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
|
||||
return *mockEmptyResponse, errors.New("error getting user ")
|
||||
}
|
||||
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ func TestGetUserInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
// mock function response from getUserInfo()
|
||||
minioGetUserInfoMock = func(username string) (madmin.UserInfo, error) {
|
||||
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
|
||||
return *mockResponse, nil
|
||||
}
|
||||
function := "getUserInfo()"
|
||||
@@ -294,7 +294,7 @@ func TestGetUserInfo(t *testing.T) {
|
||||
assert.Equal(mockResponse.Status, info.Status)
|
||||
|
||||
// Test-2 : getUserInfo() Return error and see that the error is handled correctly and returned
|
||||
minioGetUserInfoMock = func(username string) (madmin.UserInfo, error) {
|
||||
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
|
||||
return *emptyMockResponse, errors.New("error")
|
||||
}
|
||||
_, err = getUserInfo(ctx, adminClient, userName)
|
||||
@@ -313,7 +313,7 @@ func TestSetUserStatus(t *testing.T) {
|
||||
|
||||
// Test-1: setUserStatus() update valid disabled status
|
||||
expectedStatus := "disabled"
|
||||
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
|
||||
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); err != nil {
|
||||
@@ -321,7 +321,7 @@ func TestSetUserStatus(t *testing.T) {
|
||||
}
|
||||
// Test-2: setUserStatus() update valid enabled status
|
||||
expectedStatus = "enabled"
|
||||
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
|
||||
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); err != nil {
|
||||
@@ -329,7 +329,7 @@ func TestSetUserStatus(t *testing.T) {
|
||||
}
|
||||
// Test-3: setUserStatus() update invalid status, should send error
|
||||
expectedStatus = "invalid"
|
||||
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
|
||||
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
|
||||
return nil
|
||||
}
|
||||
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); assert.Error(err) {
|
||||
@@ -337,7 +337,7 @@ func TestSetUserStatus(t *testing.T) {
|
||||
}
|
||||
// Test-4: setUserStatus() handler error correctly
|
||||
expectedStatus = "enabled"
|
||||
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
|
||||
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); assert.Error(err) {
|
||||
@@ -358,7 +358,7 @@ func TestUserGroupsBulk(t *testing.T) {
|
||||
|
||||
// Test-1: addUsersListToGroups() updates the groups for a users list
|
||||
// mock function response from updateUserGroups(accessKey, groupsToAssign)
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ func TestUserGroupsBulk(t *testing.T) {
|
||||
|
||||
// Test-2: addUsersListToGroups() make sure errors are handled correctly when error on updateGroupMembers()
|
||||
// mock function response from removeUser(accessKey)
|
||||
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
|
||||
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ func TestListUsersWithAccessToBucket(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, _ := listUsersWithAccessToBucket(ctx, adminClient, tt.args.bucket)
|
||||
assert.Equal(got, tt.want)
|
||||
})
|
||||
|
||||
@@ -76,7 +76,7 @@ func Test_computeObjectURLWithoutEncode(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, err := computeObjectURLWithoutEncode(tt.args.bucketName, tt.args.prefix)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("computeObjectURLWithoutEncode() errors = %v, wantErr %v", err, tt.wantErr)
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestGetPort(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsolePort, tt.args.env)
|
||||
assert.Equalf(t, tt.want, GetPort(), "GetPort()")
|
||||
os.Unsetenv(ConsolePort)
|
||||
@@ -87,7 +87,7 @@ func TestGetTLSPort(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleTLSPort, tt.args.env)
|
||||
assert.Equalf(t, tt.want, GetTLSPort(), "GetTLSPort()")
|
||||
os.Unsetenv(ConsoleTLSPort)
|
||||
@@ -120,7 +120,7 @@ func TestGetSecureAllowedHosts(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleSecureAllowedHosts, tt.args.env)
|
||||
assert.Equalf(t, tt.want, GetSecureAllowedHosts(), "GetSecureAllowedHosts()")
|
||||
os.Unsetenv(ConsoleSecureAllowedHosts)
|
||||
@@ -153,7 +153,7 @@ func TestGetSecureHostsProxyHeaders(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleSecureHostsProxyHeaders, tt.args.env)
|
||||
assert.Equalf(t, tt.want, GetSecureHostsProxyHeaders(), "GetSecureHostsProxyHeaders()")
|
||||
os.Unsetenv(ConsoleSecureHostsProxyHeaders)
|
||||
@@ -186,7 +186,7 @@ func TestGetSecureSTSSeconds(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleSecureSTSSeconds, tt.args.env)
|
||||
assert.Equalf(t, tt.want, GetSecureSTSSeconds(), "GetSecureSTSSeconds()")
|
||||
os.Unsetenv(ConsoleSecureSTSSeconds)
|
||||
@@ -219,7 +219,7 @@ func Test_getLogSearchAPIToken(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleLogQueryAuthToken, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getLogSearchAPIToken(), "getLogSearchAPIToken()")
|
||||
os.Setenv(ConsoleLogQueryAuthToken, tt.args.env)
|
||||
@@ -252,7 +252,7 @@ func Test_getPrometheusURL(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(PrometheusURL, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getPrometheusURL(), "getPrometheusURL()")
|
||||
os.Setenv(PrometheusURL, tt.args.env)
|
||||
@@ -285,7 +285,7 @@ func Test_getPrometheusJobID(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(PrometheusJobID, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getPrometheusJobID(), "getPrometheusJobID()")
|
||||
os.Setenv(PrometheusJobID, tt.args.env)
|
||||
@@ -318,7 +318,7 @@ func Test_getMaxConcurrentUploadsLimit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleMaxConcurrentUploads, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getMaxConcurrentUploadsLimit(), "getMaxConcurrentUploadsLimit()")
|
||||
os.Unsetenv(ConsoleMaxConcurrentUploads)
|
||||
@@ -351,7 +351,7 @@ func Test_getMaxConcurrentDownloadsLimit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleMaxConcurrentDownloads, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getMaxConcurrentDownloadsLimit(), "getMaxConcurrentDownloadsLimit()")
|
||||
os.Unsetenv(ConsoleMaxConcurrentDownloads)
|
||||
@@ -384,7 +384,7 @@ func Test_getConsoleDevMode(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
os.Setenv(ConsoleDevMode, tt.args.env)
|
||||
assert.Equalf(t, tt.want, getConsoleDevMode(), "getConsoleDevMode()")
|
||||
os.Unsetenv(ConsoleDevMode)
|
||||
|
||||
@@ -82,7 +82,7 @@ func configureFlags(api *operations.ConsoleAPI) {
|
||||
|
||||
func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
// Applies when the "x-token" header is set
|
||||
api.KeyAuth = func(token string, scopes []string) (*models.Principal, error) {
|
||||
api.KeyAuth = func(token string, _ []string) (*models.Principal, error) {
|
||||
// we are validating the session token by decrypting the claims inside, if the operation succeed that means the jwt
|
||||
// was generated and signed by us in the first place
|
||||
if token == "Anonymous" {
|
||||
@@ -103,7 +103,7 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
CustomStyleOb: claims.CustomStyleOB,
|
||||
}, nil
|
||||
}
|
||||
api.AnonymousAuth = func(s string) (*models.Principal, error) {
|
||||
api.AnonymousAuth = func(_ string) (*models.Principal, error) {
|
||||
return &models.Principal{}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ func Test_parseSubPath(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, parseSubPath(tt.args.v), "parseSubPath(%v)", tt.args.v)
|
||||
})
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func Test_getSubPath(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
t.Setenv(SubPath, tt.args.envValue)
|
||||
defer os.Unsetenv(SubPath)
|
||||
subPathOnce = sync.Once{}
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestError(t *testing.T) {
|
||||
})
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got := Error(tt.args.err...)
|
||||
assert.Equalf(t, tt.want.Code, got.Code, "Error(%v) Got (%v)", tt.want.Code, got.Code)
|
||||
assert.Equalf(t, tt.want.APIError.DetailedMessage, got.APIError.DetailedMessage, "Error(%s) Got (%s)", tt.want.APIError.DetailedMessage, got.APIError.DetailedMessage)
|
||||
@@ -152,7 +152,7 @@ func TestErrorWithContext(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, ErrorWithContext(tt.args.ctx, tt.args.err...), "ErrorWithContext(%v, %v)", tt.args.ctx, tt.args.err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestContext_Load(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
c := &Context{}
|
||||
|
||||
fs := flag.NewFlagSet("flags", flag.ContinueOnError)
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestReplacePolicyVariables(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got := ReplacePolicyVariables(tt.args.claims, tt.args.accountInfo)
|
||||
policy, err := minioIAMPolicy.ParseConfig(bytes.NewReader(got))
|
||||
if (err != nil) != tt.wantErr {
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestAddServiceAccount(t *testing.T) {
|
||||
AccessKey: "minio",
|
||||
SecretKey: "minio123",
|
||||
}
|
||||
minioAddServiceAccountMock = func(ctx context.Context, policy *iampolicy.Policy, user string, accessKey string, secretKey string, name string, description string, expiry *time.Time, comment string) (madmin.Credentials, error) {
|
||||
minioAddServiceAccountMock = func(_ context.Context, _ *iampolicy.Policy, _ string, _ string, _ string, _ string, _ string, _ *time.Time, _ string) (madmin.Credentials, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
saCreds, err := createServiceAccount(ctx, client, policyDefinition, "", "", nil, "")
|
||||
@@ -57,7 +57,7 @@ func TestAddServiceAccount(t *testing.T) {
|
||||
AccessKey: "minio",
|
||||
SecretKey: "minio123",
|
||||
}
|
||||
minioAddServiceAccountMock = func(ctx context.Context, policy *iampolicy.Policy, user string, accessKey string, secretKey string, name string, description string, expiry *time.Time, comment string) (madmin.Credentials, error) {
|
||||
minioAddServiceAccountMock = func(_ context.Context, _ *iampolicy.Policy, _ string, _ string, _ string, _ string, _ string, _ *time.Time, _ string) (madmin.Credentials, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
_, err = createServiceAccount(ctx, client, policyDefinition, "", "", nil, "")
|
||||
@@ -69,7 +69,7 @@ func TestAddServiceAccount(t *testing.T) {
|
||||
AccessKey: "minio",
|
||||
SecretKey: "minio123",
|
||||
}
|
||||
minioAddServiceAccountMock = func(ctx context.Context, policy *iampolicy.Policy, user string, accessKey string, secretKey string, name string, description string, expiry *time.Time, comment string) (madmin.Credentials, error) {
|
||||
minioAddServiceAccountMock = func(_ context.Context, _ *iampolicy.Policy, _ string, _ string, _ string, _ string, _ string, _ *time.Time, _ string) (madmin.Credentials, error) {
|
||||
return madmin.Credentials{}, errors.New("error")
|
||||
}
|
||||
_, err = createServiceAccount(ctx, client, policyDefinition, "", "", nil, "")
|
||||
@@ -96,7 +96,7 @@ func TestListServiceAccounts(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
minioListServiceAccountsMock = func(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error) {
|
||||
minioListServiceAccountsMock = func(_ context.Context, _ string) (madmin.ListServiceAccountsResp, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestListServiceAccounts(t *testing.T) {
|
||||
Description: "",
|
||||
Expiration: nil,
|
||||
}
|
||||
minioInfoServiceAccountMock = func(ctx context.Context, serviceAccount string) (madmin.InfoServiceAccountResp, error) {
|
||||
minioInfoServiceAccountMock = func(_ context.Context, _ string) (madmin.InfoServiceAccountResp, error) {
|
||||
return mockInfoResp, nil
|
||||
}
|
||||
_, err := getUserServiceAccounts(ctx, client, "")
|
||||
@@ -118,7 +118,7 @@ func TestListServiceAccounts(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: getUserServiceAccounts returns an error, handle it properly
|
||||
minioListServiceAccountsMock = func(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error) {
|
||||
minioListServiceAccountsMock = func(_ context.Context, _ string) (madmin.ListServiceAccountsResp, error) {
|
||||
return madmin.ListServiceAccountsResp{}, errors.New("error")
|
||||
}
|
||||
_, err = getUserServiceAccounts(ctx, client, "")
|
||||
@@ -137,7 +137,7 @@ func TestDeleteServiceAccount(t *testing.T) {
|
||||
|
||||
// Test-1: deleteServiceAccount receive a service account to delete
|
||||
testServiceAccount := "accesskeytest"
|
||||
minioDeleteServiceAccountMock = func(ctx context.Context, serviceAccount string) error {
|
||||
minioDeleteServiceAccountMock = func(_ context.Context, _ string) error {
|
||||
return nil
|
||||
}
|
||||
if err := deleteServiceAccount(ctx, client, testServiceAccount); err != nil {
|
||||
@@ -145,7 +145,7 @@ func TestDeleteServiceAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: if an invalid policy is assigned to the service account, this will raise an error
|
||||
minioDeleteServiceAccountMock = func(ctx context.Context, serviceAccount string) error {
|
||||
minioDeleteServiceAccountMock = func(_ context.Context, _ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func TestGetServiceAccountDetails(t *testing.T) {
|
||||
}`,
|
||||
}
|
||||
|
||||
minioInfoServiceAccountMock = func(ctx context.Context, user string) (madmin.InfoServiceAccountResp, error) {
|
||||
minioInfoServiceAccountMock = func(_ context.Context, _ string) (madmin.InfoServiceAccountResp, error) {
|
||||
return mockResponse, nil
|
||||
}
|
||||
serviceAccount, err := getServiceAccountDetails(ctx, client, "")
|
||||
@@ -191,7 +191,7 @@ func TestGetServiceAccountDetails(t *testing.T) {
|
||||
assert.Equal(mockResponse.Policy, serviceAccount.Policy)
|
||||
|
||||
// Test-2: getServiceAccountPolicy returns an error, handle it properly
|
||||
minioInfoServiceAccountMock = func(ctx context.Context, user string) (madmin.InfoServiceAccountResp, error) {
|
||||
minioInfoServiceAccountMock = func(_ context.Context, _ string) (madmin.InfoServiceAccountResp, error) {
|
||||
return madmin.InfoServiceAccountResp{}, errors.New("error")
|
||||
}
|
||||
_, err = getServiceAccountDetails(ctx, client, "")
|
||||
|
||||
@@ -75,7 +75,7 @@ func Test_changePassword(t *testing.T) {
|
||||
newSecretKey: "TESTTEST2",
|
||||
},
|
||||
mock: func() {
|
||||
minioChangePasswordMock = func(ctx context.Context, accessKey, secretKey string) error {
|
||||
minioChangePasswordMock = func(_ context.Context, _, _ string) error {
|
||||
return nil
|
||||
}
|
||||
},
|
||||
@@ -92,7 +92,7 @@ func Test_changePassword(t *testing.T) {
|
||||
newSecretKey: "TESTTEST2",
|
||||
},
|
||||
mock: func() {
|
||||
minioChangePasswordMock = func(ctx context.Context, accessKey, secretKey string) error {
|
||||
minioChangePasswordMock = func(_ context.Context, _, _ string) error {
|
||||
return errors.New("there was an error, please try again")
|
||||
}
|
||||
},
|
||||
@@ -110,7 +110,7 @@ func Test_changePassword(t *testing.T) {
|
||||
newSecretKey: "TESTTEST2",
|
||||
},
|
||||
mock: func() {
|
||||
minioChangePasswordMock = func(ctx context.Context, accessKey, secretKey string) error {
|
||||
minioChangePasswordMock = func(_ context.Context, _, _ string) error {
|
||||
return errors.New("there was an error, please try again")
|
||||
}
|
||||
},
|
||||
@@ -118,7 +118,7 @@ func Test_changePassword(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.mock != nil {
|
||||
tt.mock()
|
||||
}
|
||||
|
||||
@@ -648,7 +648,6 @@ func getPutBucketTagsResponse(session *models.Principal, params bucketApi.PutBuc
|
||||
}
|
||||
|
||||
err = minioClient.SetBucketTagging(ctx, bucketName, newTagSet)
|
||||
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestAddBucketNotification(t *testing.T) {
|
||||
testPrefix := ""
|
||||
testSuffix := ""
|
||||
testIgnoreExisting := false
|
||||
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
|
||||
mcAddNotificationConfigMock = func(_ context.Context, _ string, _ []string, _, _ string, _ bool) *probe.Error {
|
||||
return nil
|
||||
}
|
||||
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
|
||||
@@ -85,7 +85,7 @@ func TestAddBucketNotification(t *testing.T) {
|
||||
testPrefix = "photos/"
|
||||
testSuffix = ".jpg"
|
||||
testIgnoreExisting = true
|
||||
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
|
||||
mcAddNotificationConfigMock = func(_ context.Context, _ string, _ []string, _, _ string, _ bool) *probe.Error {
|
||||
return nil
|
||||
}
|
||||
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); err != nil {
|
||||
@@ -93,7 +93,7 @@ func TestAddBucketNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-3 createBucketEvent() S3Client.AddNotificationConfig returns an error and is handled correctly
|
||||
mcAddNotificationConfigMock = func(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error {
|
||||
mcAddNotificationConfigMock = func(_ context.Context, _ string, _ []string, _, _ string, _ bool) *probe.Error {
|
||||
return probe.NewError(errors.New("error"))
|
||||
}
|
||||
if err := createBucketEvent(ctx, client, testArn, testNotificationEvents, testPrefix, testSuffix, testIgnoreExisting); assert.Error(err) {
|
||||
@@ -118,7 +118,7 @@ func TestDeleteBucketNotification(t *testing.T) {
|
||||
}
|
||||
prefix := "/photos"
|
||||
suffix := ".jpg"
|
||||
mcRemoveNotificationConfigMock = func(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
|
||||
mcRemoveNotificationConfigMock = func(_ context.Context, _ string, _ string, _ string, _ string) *probe.Error {
|
||||
return nil
|
||||
}
|
||||
if err := deleteBucketEventNotification(ctx, client, testArn, events, swag.String(prefix), swag.String(suffix)); err != nil {
|
||||
@@ -126,7 +126,7 @@ func TestDeleteBucketNotification(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2 deleteBucketEventNotification() S3Client.DeleteBucketEventNotification returns an error and is handled correctly
|
||||
mcRemoveNotificationConfigMock = func(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error {
|
||||
mcRemoveNotificationConfigMock = func(_ context.Context, _ string, _ string, _ string, _ string) *probe.Error {
|
||||
return probe.NewError(errors.New("error"))
|
||||
}
|
||||
if err := deleteBucketEventNotification(ctx, client, testArn, events, swag.String(prefix), swag.String(suffix)); assert.Error(err) {
|
||||
@@ -191,7 +191,7 @@ func TestListBucketEvents(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
minioGetBucketNotificationMock = func(ctx context.Context, bucketName string) (bucketNotification notification.Configuration, err error) {
|
||||
minioGetBucketNotificationMock = func(_ context.Context, _ string) (bucketNotification notification.Configuration, err error) {
|
||||
return mockBucketN, nil
|
||||
}
|
||||
eventConfigs, err := listBucketEvents(minClient, "bucket")
|
||||
@@ -238,7 +238,7 @@ func TestListBucketEvents(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
minioGetBucketNotificationMock = func(ctx context.Context, bucketName string) (bucketNotification notification.Configuration, err error) {
|
||||
minioGetBucketNotificationMock = func(_ context.Context, _ string) (bucketNotification notification.Configuration, err error) {
|
||||
return mockBucketN, nil
|
||||
}
|
||||
eventConfigs, err = listBucketEvents(minClient, "bucket")
|
||||
@@ -357,7 +357,7 @@ func TestListBucketEvents(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
minioGetBucketNotificationMock = func(ctx context.Context, bucketName string) (bucketNotification notification.Configuration, err error) {
|
||||
minioGetBucketNotificationMock = func(_ context.Context, _ string) (bucketNotification notification.Configuration, err error) {
|
||||
return mockBucketN, nil
|
||||
}
|
||||
eventConfigs, err = listBucketEvents(minClient, "bucket")
|
||||
@@ -378,7 +378,7 @@ func TestListBucketEvents(t *testing.T) {
|
||||
}
|
||||
|
||||
////// Test-2 : listBucketEvents() Returns error and see that the error is handled correctly and returned
|
||||
minioGetBucketNotificationMock = func(ctx context.Context, bucketName string) (bucketNotification notification.Configuration, err error) {
|
||||
minioGetBucketNotificationMock = func(_ context.Context, _ string) (bucketNotification notification.Configuration, err error) {
|
||||
return notification.Configuration{}, errors.New("error")
|
||||
}
|
||||
_, err = listBucketEvents(minClient, "bucket")
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestGetLifecycleRules(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestGetLifecycleRules(t *testing.T) {
|
||||
Lifecycle: []*models.ObjectBucketLifecycle{},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycleT2, nil
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestGetLifecycleRules(t *testing.T) {
|
||||
|
||||
// Test-3 : getBucketLifecycle() get list of events returns an error
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return nil, errors.New("error returned")
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func TestSetLifecycleRule(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ func TestSetLifecycleRule(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ func TestSetLifecycleRule(t *testing.T) {
|
||||
|
||||
// Test-2 : addBucketLifecycle() returns error
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return errors.New("error setting lifecycle")
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ func TestUpdateLifecycleRule(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func TestUpdateLifecycleRule(t *testing.T) {
|
||||
LifecycleID: "TESTRULE",
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ func TestUpdateLifecycleRule(t *testing.T) {
|
||||
LifecycleID: "TESTRULE",
|
||||
}
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ func TestUpdateLifecycleRule(t *testing.T) {
|
||||
|
||||
// Test-3 : editBucketLifecycle() returns error
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return errors.New("error setting lifecycle")
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ func TestDeleteLifecycleRule(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
minioSetBucketLifecycleMock = func(ctx context.Context, bucketName string, config *lifecycle.Configuration) error {
|
||||
minioSetBucketLifecycleMock = func(_ context.Context, _ string, _ *lifecycle.Configuration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ func TestDeleteLifecycleRule(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle, nil
|
||||
}
|
||||
|
||||
@@ -360,7 +360,7 @@ func TestDeleteLifecycleRule(t *testing.T) {
|
||||
Rules: []lifecycle.Rule{},
|
||||
}
|
||||
|
||||
minioGetLifecycleRulesMock = func(ctx context.Context, bucketName string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
minioGetLifecycleRulesMock = func(_ context.Context, _ string) (lifecycle *lifecycle.Configuration, err error) {
|
||||
return &mockLifecycle2, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestMakeBucket(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
// Test-1: makeBucket() create a bucket
|
||||
// mock function response from makeBucketWithContext(ctx)
|
||||
minioMakeBucketWithContextMock = func(ctx context.Context, bucketName, location string, objectLock bool) error {
|
||||
minioMakeBucketWithContextMock = func(_ context.Context, _, _ string, _ bool) error {
|
||||
return nil
|
||||
}
|
||||
if err := makeBucket(ctx, minClient, "bucktest1", true); err != nil {
|
||||
@@ -153,7 +153,7 @@ func TestMakeBucket(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2 makeBucket() make sure errors are handled correctly when errors on MakeBucketWithContext
|
||||
minioMakeBucketWithContextMock = func(ctx context.Context, bucketName, location string, objectLock bool) error {
|
||||
minioMakeBucketWithContextMock = func(_ context.Context, _, _ string, _ bool) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := makeBucket(ctx, minClient, "bucktest1", true); assert.Error(err) {
|
||||
@@ -169,7 +169,7 @@ func TestDeleteBucket(t *testing.T) {
|
||||
|
||||
// Test-1: removeBucket() delete a bucket
|
||||
// mock function response from removeBucket(bucketName)
|
||||
minioRemoveBucketMock = func(bucketName string) error {
|
||||
minioRemoveBucketMock = func(_ string) error {
|
||||
return nil
|
||||
}
|
||||
if err := removeBucket(minClient, "bucktest1"); err != nil {
|
||||
@@ -178,7 +178,7 @@ func TestDeleteBucket(t *testing.T) {
|
||||
|
||||
// Test-2: removeBucket() make sure errors are handled correctly when errors on DeleteBucket()
|
||||
// mock function response from removeBucket(bucketName)
|
||||
minioRemoveBucketMock = func(bucketName string) error {
|
||||
minioRemoveBucketMock = func(_ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := removeBucket(minClient, "bucktest1"); assert.Error(err) {
|
||||
@@ -197,7 +197,7 @@ func TestBucketInfo(t *testing.T) {
|
||||
// Test-1: getBucketInfo() get a bucket with PRIVATE access
|
||||
// if not policy set on bucket, access should be PRIVATE
|
||||
mockPolicy := ""
|
||||
minioGetBucketPolicyMock = func(bucketName string) (string, error) {
|
||||
minioGetBucketPolicyMock = func(_ string) (string, error) {
|
||||
return mockPolicy, nil
|
||||
}
|
||||
bucketToSet := "csbucket"
|
||||
@@ -239,7 +239,7 @@ func TestBucketInfo(t *testing.T) {
|
||||
Policy: []byte(infoPolicy),
|
||||
}
|
||||
// mock function response from listBucketsWithContext(ctx)
|
||||
minioAccountInfoMock = func(ctx context.Context) (madmin.AccountInfo, error) {
|
||||
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
|
||||
return mockBucketList, nil
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ func TestBucketInfo(t *testing.T) {
|
||||
// Test-2: getBucketInfo() get a bucket with PUBLIC access
|
||||
// mock policy for bucket csbucket with readWrite access (should return PUBLIC)
|
||||
mockPolicy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetBucketLocation\",\"s3:ListBucket\",\"s3:ListBucketMultipartUploads\"],\"Resource\":[\"arn:aws:s3:::csbucket\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:GetObject\",\"s3:ListMultipartUploadParts\",\"s3:PutObject\",\"s3:AbortMultipartUpload\",\"s3:DeleteObject\"],\"Resource\":[\"arn:aws:s3:::csbucket/*\"]}]}"
|
||||
minioGetBucketPolicyMock = func(bucketName string) (string, error) {
|
||||
minioGetBucketPolicyMock = func(_ string) (string, error) {
|
||||
return mockPolicy, nil
|
||||
}
|
||||
bucketToSet = "csbucket"
|
||||
@@ -278,9 +278,9 @@ func TestBucketInfo(t *testing.T) {
|
||||
assert.Equal(outputExpected.Objects, bucketInfo.Objects)
|
||||
|
||||
// Test-3: getBucketInfo() get a bucket with PRIVATE access
|
||||
// if bucket has a null statement, the the bucket is PRIVATE
|
||||
// if bucket has a null statement, the bucket is PRIVATE
|
||||
mockPolicy = "{\"Version\":\"2012-10-17\",\"Statement\":[]}"
|
||||
minioGetBucketPolicyMock = func(bucketName string) (string, error) {
|
||||
minioGetBucketPolicyMock = func(_ string) (string, error) {
|
||||
return mockPolicy, nil
|
||||
}
|
||||
bucketToSet = "csbucket"
|
||||
@@ -303,7 +303,7 @@ func TestBucketInfo(t *testing.T) {
|
||||
|
||||
// Test-4: getBucketInfo() returns an errors while parsing invalid policy
|
||||
mockPolicy = "policyinvalid"
|
||||
minioGetBucketPolicyMock = func(bucketName string) (string, error) {
|
||||
minioGetBucketPolicyMock = func(_ string) (string, error) {
|
||||
return mockPolicy, nil
|
||||
}
|
||||
bucketToSet = "csbucket"
|
||||
@@ -331,7 +331,7 @@ func TestSetBucketAccess(t *testing.T) {
|
||||
function := "setBucketAccessPolicy()"
|
||||
// Test-1: setBucketAccessPolicy() set a bucket's access policy
|
||||
// mock function response from setBucketPolicyWithContext(ctx)
|
||||
minioSetBucketPolicyWithContextMock = func(ctx context.Context, bucketName, policy string) error {
|
||||
minioSetBucketPolicyWithContextMock = func(_ context.Context, _, _ string) error {
|
||||
return nil
|
||||
}
|
||||
if err := setBucketAccessPolicy(ctx, minClient, "bucktest1", models.BucketAccessPUBLIC, ""); err != nil {
|
||||
@@ -359,7 +359,7 @@ func TestSetBucketAccess(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-5: setBucketAccessPolicy() handle errors on SetPolicy call
|
||||
minioSetBucketPolicyWithContextMock = func(ctx context.Context, bucketName, policy string) error {
|
||||
minioSetBucketPolicyWithContextMock = func(_ context.Context, _, _ string) error {
|
||||
return errors.New("error")
|
||||
}
|
||||
if err := setBucketAccessPolicy(ctx, minClient, "bucktest1", models.BucketAccessPUBLIC, ""); assert.Error(err) {
|
||||
@@ -390,7 +390,7 @@ func Test_enableBucketEncryption(t *testing.T) {
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
encryptionType: "sse-s3",
|
||||
mockEnableBucketEncryptionFunc: func(ctx context.Context, bucketName string, config *sse.Configuration) error {
|
||||
mockEnableBucketEncryptionFunc: func(_ context.Context, _ string, _ *sse.Configuration) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -403,7 +403,7 @@ func Test_enableBucketEncryption(t *testing.T) {
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
encryptionType: "sse-s3",
|
||||
mockEnableBucketEncryptionFunc: func(ctx context.Context, bucketName string, config *sse.Configuration) error {
|
||||
mockEnableBucketEncryptionFunc: func(_ context.Context, _ string, _ *sse.Configuration) error {
|
||||
return ErrInvalidSession
|
||||
},
|
||||
},
|
||||
@@ -411,7 +411,7 @@ func Test_enableBucketEncryption(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioSetBucketEncryptionMock = tt.args.mockEnableBucketEncryptionFunc
|
||||
if err := enableBucketEncryption(tt.args.ctx, tt.args.client, tt.args.bucketName, tt.args.encryptionType, tt.args.kmsKeyID); (err != nil) != tt.wantErr {
|
||||
t.Errorf("enableBucketEncryption() errors = %v, wantErr %v", err, tt.wantErr)
|
||||
@@ -440,7 +440,7 @@ func Test_disableBucketEncryption(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
mockBucketDisableFunc: func(ctx context.Context, bucketName string) error {
|
||||
mockBucketDisableFunc: func(_ context.Context, _ string) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -452,7 +452,7 @@ func Test_disableBucketEncryption(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
mockBucketDisableFunc: func(ctx context.Context, bucketName string) error {
|
||||
mockBucketDisableFunc: func(_ context.Context, _ string) error {
|
||||
return ErrDefault
|
||||
},
|
||||
},
|
||||
@@ -460,7 +460,7 @@ func Test_disableBucketEncryption(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioRemoveBucketEncryptionMock = tt.args.mockBucketDisableFunc
|
||||
if err := disableBucketEncryption(tt.args.ctx, tt.args.client, tt.args.bucketName); (err != nil) != tt.wantErr {
|
||||
t.Errorf("disableBucketEncryption() errors = %v, wantErr %v", err, tt.wantErr)
|
||||
@@ -490,7 +490,7 @@ func Test_getBucketEncryptionInfo(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
mockBucketEncryptionGet: func(ctx context.Context, bucketName string) (*sse.Configuration, error) {
|
||||
mockBucketEncryptionGet: func(_ context.Context, _ string) (*sse.Configuration, error) {
|
||||
return &sse.Configuration{
|
||||
Rules: []sse.Rule{
|
||||
{
|
||||
@@ -512,7 +512,7 @@ func Test_getBucketEncryptionInfo(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
mockBucketEncryptionGet: func(ctx context.Context, bucketName string) (*sse.Configuration, error) {
|
||||
mockBucketEncryptionGet: func(_ context.Context, _ string) (*sse.Configuration, error) {
|
||||
return &sse.Configuration{
|
||||
Rules: []sse.Rule{},
|
||||
}, nil
|
||||
@@ -526,7 +526,7 @@ func Test_getBucketEncryptionInfo(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
mockBucketEncryptionGet: func(ctx context.Context, bucketName string) (*sse.Configuration, error) {
|
||||
mockBucketEncryptionGet: func(_ context.Context, _ string) (*sse.Configuration, error) {
|
||||
return nil, ErrSSENotConfigured
|
||||
},
|
||||
},
|
||||
@@ -534,7 +534,7 @@ func Test_getBucketEncryptionInfo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioGetBucketEncryptionMock = tt.args.mockBucketEncryptionGet
|
||||
got, err := getBucketEncryptionInfo(tt.args.ctx, tt.args.client, tt.args.bucketName)
|
||||
if (err != nil) != tt.wantErr {
|
||||
@@ -575,7 +575,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionModeCompliance,
|
||||
unit: models.ObjectRetentionUnitDays,
|
||||
validity: swag.Int32(2),
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -590,7 +590,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionModeGovernance,
|
||||
unit: models.ObjectRetentionUnitYears,
|
||||
validity: swag.Int32(2),
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -605,7 +605,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionModeCompliance,
|
||||
unit: models.ObjectRetentionUnitDays,
|
||||
validity: nil,
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -620,7 +620,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionMode("othermode"),
|
||||
unit: models.ObjectRetentionUnitDays,
|
||||
validity: swag.Int32(2),
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -635,7 +635,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionModeCompliance,
|
||||
unit: models.ObjectRetentionUnit("otherunit"),
|
||||
validity: swag.Int32(2),
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -650,7 +650,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
mode: models.ObjectRetentionModeCompliance,
|
||||
unit: models.ObjectRetentionUnitDays,
|
||||
validity: swag.Int32(2),
|
||||
mockBucketRetentionFunc: func(ctx context.Context, bucketName string, mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit) error {
|
||||
mockBucketRetentionFunc: func(_ context.Context, _ string, _ *minio.RetentionMode, _ *uint, _ *minio.ValidityUnit) error {
|
||||
return errors.New("error func")
|
||||
},
|
||||
},
|
||||
@@ -658,7 +658,7 @@ func Test_SetBucketRetentionConfig(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioSetObjectLockConfigMock = tt.args.mockBucketRetentionFunc
|
||||
err := setBucketRetentionConfig(tt.args.ctx, tt.args.client, tt.args.bucketName, tt.args.mode, tt.args.unit, tt.args.validity)
|
||||
if tt.expectedError != nil {
|
||||
@@ -693,7 +693,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
m := minio.Governance
|
||||
u := minio.Days
|
||||
return &m, swag.Uint(2), &u, nil
|
||||
@@ -712,7 +712,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
m := minio.Compliance
|
||||
u := minio.Days
|
||||
return &m, swag.Uint(2), &u, nil
|
||||
@@ -731,7 +731,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
return nil, nil, nil, errors.New("error func")
|
||||
},
|
||||
},
|
||||
@@ -746,7 +746,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
return nil, nil, nil, minio.ErrorResponse{
|
||||
Code: "ObjectLockConfigurationNotFoundError",
|
||||
Message: "Object Lock configuration does not exist for this bucket",
|
||||
@@ -762,7 +762,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
m := minio.RetentionMode("other")
|
||||
u := minio.Days
|
||||
return &m, swag.Uint(2), &u, nil
|
||||
@@ -777,7 +777,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
ctx: ctx,
|
||||
client: minClient,
|
||||
bucketName: "test",
|
||||
getRetentionFunc: func(ctx context.Context, bucketName string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
getRetentionFunc: func(_ context.Context, _ string) (mode *minio.RetentionMode, validity *uint, unit *minio.ValidityUnit, err error) {
|
||||
m := minio.Governance
|
||||
u := minio.ValidityUnit("otherUnit")
|
||||
return &m, swag.Uint(2), &u, nil
|
||||
@@ -789,7 +789,7 @@ func Test_GetBucketRetentionConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioGetBucketObjectLockConfigMock = tt.args.getRetentionFunc
|
||||
resp, err := getBucketRetentionConfig(tt.args.ctx, tt.args.client, tt.args.bucketName)
|
||||
|
||||
@@ -833,7 +833,7 @@ func Test_SetBucketVersioning(t *testing.T) {
|
||||
state: VersionEnable,
|
||||
bucketName: "test",
|
||||
client: minClient,
|
||||
setVersioningFunc: func(ctx context.Context, state string, excludePrefix []string, excludeFolders bool) *probe.Error {
|
||||
setVersioningFunc: func(_ context.Context, _ string, _ []string, _ bool) *probe.Error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -847,7 +847,7 @@ func Test_SetBucketVersioning(t *testing.T) {
|
||||
excludePrefix: []string{"prefix1", "prefix2"},
|
||||
bucketName: "test",
|
||||
client: minClient,
|
||||
setVersioningFunc: func(ctx context.Context, state string, excludePrefix []string, excludeFolders bool) *probe.Error {
|
||||
setVersioningFunc: func(_ context.Context, _ string, _ []string, _ bool) *probe.Error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -862,7 +862,7 @@ func Test_SetBucketVersioning(t *testing.T) {
|
||||
excludeFolders: true,
|
||||
bucketName: "test",
|
||||
client: minClient,
|
||||
setVersioningFunc: func(ctx context.Context, state string, excludePrefix []string, excludeFolders bool) *probe.Error {
|
||||
setVersioningFunc: func(_ context.Context, _ string, _ []string, _ bool) *probe.Error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -875,7 +875,7 @@ func Test_SetBucketVersioning(t *testing.T) {
|
||||
state: VersionEnable,
|
||||
bucketName: "test",
|
||||
client: minClient,
|
||||
setVersioningFunc: func(ctx context.Context, state string, excludePrefix []string, excludeFolders bool) *probe.Error {
|
||||
setVersioningFunc: func(_ context.Context, _ string, _ []string, _ bool) *probe.Error {
|
||||
return probe.NewError(errors.New(errorMsg))
|
||||
},
|
||||
},
|
||||
@@ -884,7 +884,7 @@ func Test_SetBucketVersioning(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
minioSetVersioningMock = tt.args.setVersioningFunc
|
||||
|
||||
err := doSetVersioning(tt.args.ctx, tt.args.client, tt.args.state, tt.args.excludePrefix, tt.args.excludeFolders)
|
||||
@@ -1199,9 +1199,9 @@ func Test_getAccountBuckets(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// mock function response from listBucketsWithContext(ctx)
|
||||
minioAccountInfoMock = func(ctx context.Context) (madmin.AccountInfo, error) {
|
||||
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
|
||||
return tt.args.mockBucketList, tt.args.mockError
|
||||
}
|
||||
client := AdminClientMock{}
|
||||
@@ -1268,7 +1268,7 @@ func Test_getMaxShareLinkExpirationSeconds(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.preFunc != nil {
|
||||
tt.preFunc()
|
||||
}
|
||||
|
||||
@@ -97,8 +97,8 @@ func TestLogSearch(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
testRequest := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
testRequest := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(tt.args.apiResponseCode)
|
||||
fmt.Fprintln(w, tt.args.apiResponse)
|
||||
}))
|
||||
|
||||
@@ -125,14 +125,14 @@ func Test_validateUserAgainstIDP(t *testing.T) {
|
||||
want: nil,
|
||||
wantErr: true,
|
||||
mockFunc: func() {
|
||||
idpVerifyIdentityMock = func(ctx context.Context, code, state string) (*credentials.Credentials, error) {
|
||||
idpVerifyIdentityMock = func(_ context.Context, _, _ string) (*credentials.Credentials, error) {
|
||||
return nil, errors.New("something went wrong")
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.mockFunc != nil {
|
||||
tt.mockFunc()
|
||||
}
|
||||
@@ -170,14 +170,14 @@ func Test_getAccountInfo(t *testing.T) {
|
||||
want: nil,
|
||||
wantErr: true,
|
||||
mockFunc: func() {
|
||||
minioAccountInfoMock = func(ctx context.Context) (madmin.AccountInfo, error) {
|
||||
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
|
||||
return madmin.AccountInfo{}, errors.New("something went wrong")
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.mockFunc != nil {
|
||||
tt.mockFunc()
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,6 @@ func uploadFiles(ctx context.Context, client MinioClient, params objectApi.PostB
|
||||
ContentType: contentType,
|
||||
DisableMultipart: true, // Do not upload as multipart stream for console uploader.
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -168,15 +168,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -222,20 +222,20 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
defer close(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -257,7 +257,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -277,15 +277,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -309,7 +309,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -333,15 +333,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -385,7 +385,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -402,13 +402,13 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
return nil, errors.New("error legal")
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
return nil, nil, errors.New("error retention")
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
return nil, errors.New("error get tags")
|
||||
},
|
||||
},
|
||||
@@ -433,7 +433,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -456,15 +456,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -501,7 +501,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -524,15 +524,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -566,7 +566,7 @@ func Test_listObjects(t *testing.T) {
|
||||
recursive: true,
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -589,15 +589,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -644,7 +644,7 @@ func Test_listObjects(t *testing.T) {
|
||||
withVersions: false,
|
||||
withMetadata: false,
|
||||
limit: swag.Int32(1),
|
||||
listFunc: func(ctx context.Context, bucket string, opts minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
listFunc: func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
|
||||
objectStatCh := make(chan minio.ObjectInfo, 1)
|
||||
go func(objectStatCh chan<- minio.ObjectInfo) {
|
||||
defer close(objectStatCh)
|
||||
@@ -667,15 +667,15 @@ func Test_listObjects(t *testing.T) {
|
||||
}(objectStatCh)
|
||||
return objectStatCh
|
||||
},
|
||||
objectLegalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
objectLegalHoldFunc: func(_ context.Context, _, _ string, _ minio.GetObjectLegalHoldOptions) (status *minio.LegalHoldStatus, err error) {
|
||||
s := minio.LegalHoldEnabled
|
||||
return &s, nil
|
||||
},
|
||||
objectRetentionFunc: func(ctx context.Context, bucketName, objectName, versionID string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
objectRetentionFunc: func(_ context.Context, _, _, _ string) (mode *minio.RetentionMode, retainUntilDate *time.Time, err error) {
|
||||
m := minio.Governance
|
||||
return &m, &tretention, nil
|
||||
},
|
||||
objectGetTaggingFunc: func(ctx context.Context, bucketName, objectName string, opts minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
objectGetTaggingFunc: func(_ context.Context, _, _ string, _ minio.GetObjectTaggingOptions) (*tags.Tags, error) {
|
||||
tagMap := map[string]string{
|
||||
"tag1": "value1",
|
||||
}
|
||||
@@ -707,7 +707,7 @@ func Test_listObjects(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
minioListObjectsMock = tt.args.listFunc
|
||||
minioGetObjectLegalHoldMock = tt.args.objectLegalHoldFunc
|
||||
minioGetObjectRetentionMock = tt.args.objectRetentionFunc
|
||||
@@ -768,7 +768,7 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: false,
|
||||
nonCurrent: false,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: nil}
|
||||
close(resultCh)
|
||||
@@ -784,7 +784,7 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: false,
|
||||
nonCurrent: false,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: probe.NewError(errors.New("probe error"))}
|
||||
close(resultCh)
|
||||
@@ -800,13 +800,13 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: true,
|
||||
nonCurrent: false,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: nil}
|
||||
close(resultCh)
|
||||
return resultCh
|
||||
},
|
||||
listFunc: func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
|
||||
listFunc: func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
|
||||
ch := make(chan *mc.ClientContent, 1)
|
||||
ch <- &mc.ClientContent{}
|
||||
close(ch)
|
||||
@@ -824,13 +824,13 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: true,
|
||||
nonCurrent: false,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: probe.NewError(errors.New("probe error"))}
|
||||
close(resultCh)
|
||||
return resultCh
|
||||
},
|
||||
listFunc: func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
|
||||
listFunc: func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
|
||||
ch := make(chan *mc.ClientContent, 1)
|
||||
ch <- &mc.ClientContent{}
|
||||
close(ch)
|
||||
@@ -846,13 +846,13 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: true,
|
||||
nonCurrent: true,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: nil}
|
||||
close(resultCh)
|
||||
return resultCh
|
||||
},
|
||||
listFunc: func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
|
||||
listFunc: func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
|
||||
ch := make(chan *mc.ClientContent, 1)
|
||||
ch <- &mc.ClientContent{}
|
||||
close(ch)
|
||||
@@ -870,13 +870,13 @@ func Test_deleteObjects(t *testing.T) {
|
||||
versionID: "",
|
||||
recursive: true,
|
||||
nonCurrent: true,
|
||||
removeFunc: func(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
removeFunc: func(_ context.Context, _, _, _, _ bool, _ <-chan *mc.ClientContent) <-chan mc.RemoveResult {
|
||||
resultCh := make(chan mc.RemoveResult, 1)
|
||||
resultCh <- mc.RemoveResult{Err: probe.NewError(errors.New("probe error"))}
|
||||
close(resultCh)
|
||||
return resultCh
|
||||
},
|
||||
listFunc: func(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
|
||||
listFunc: func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
|
||||
ch := make(chan *mc.ClientContent, 1)
|
||||
ch <- &mc.ClientContent{}
|
||||
close(ch)
|
||||
@@ -890,7 +890,7 @@ func Test_deleteObjects(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
mcListMock = tt.args.listFunc
|
||||
mcRemoveMock = tt.args.removeFunc
|
||||
err := deleteObjects(ctx, s3Client1, tt.args.bucket, tt.args.path, tt.args.versionID, tt.args.recursive, false, tt.args.nonCurrent, false)
|
||||
@@ -929,7 +929,7 @@ func Test_shareObject(t *testing.T) {
|
||||
args: args{
|
||||
versionID: "2121434",
|
||||
expires: "30s",
|
||||
shareFunc: func(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error) {
|
||||
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
|
||||
return "http://someurl", nil
|
||||
},
|
||||
},
|
||||
@@ -941,7 +941,7 @@ func Test_shareObject(t *testing.T) {
|
||||
args: args{
|
||||
versionID: "2121434",
|
||||
expires: "invalid",
|
||||
shareFunc: func(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error) {
|
||||
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
|
||||
return "http://someurl", nil
|
||||
},
|
||||
},
|
||||
@@ -952,7 +952,7 @@ func Test_shareObject(t *testing.T) {
|
||||
args: args{
|
||||
versionID: "2121434",
|
||||
expires: "",
|
||||
shareFunc: func(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error) {
|
||||
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
|
||||
return "http://someurl", nil
|
||||
},
|
||||
},
|
||||
@@ -964,7 +964,7 @@ func Test_shareObject(t *testing.T) {
|
||||
args: args{
|
||||
versionID: "2121434",
|
||||
expires: "3h",
|
||||
shareFunc: func(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error) {
|
||||
shareFunc: func(_ context.Context, _ string, _ time.Duration) (string, *probe.Error) {
|
||||
return "", probe.NewError(errors.New("probe error"))
|
||||
},
|
||||
},
|
||||
@@ -973,7 +973,7 @@ func Test_shareObject(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
mcShareDownloadMock = tt.args.shareFunc
|
||||
url, err := getShareObjectURL(ctx, client, tt.args.versionID, tt.args.expires)
|
||||
if tt.wantError != nil {
|
||||
@@ -1011,7 +1011,7 @@ func Test_putObjectLegalHold(t *testing.T) {
|
||||
versionID: "someversion",
|
||||
prefix: "folder/file.txt",
|
||||
status: models.ObjectLegalHoldStatusEnabled,
|
||||
legalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectLegalHoldOptions) error {
|
||||
legalHoldFunc: func(_ context.Context, _, _ string, _ minio.PutObjectLegalHoldOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1024,7 +1024,7 @@ func Test_putObjectLegalHold(t *testing.T) {
|
||||
versionID: "someversion",
|
||||
prefix: "folder/file.txt",
|
||||
status: models.ObjectLegalHoldStatusDisabled,
|
||||
legalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectLegalHoldOptions) error {
|
||||
legalHoldFunc: func(_ context.Context, _, _ string, _ minio.PutObjectLegalHoldOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1037,7 +1037,7 @@ func Test_putObjectLegalHold(t *testing.T) {
|
||||
versionID: "someversion",
|
||||
prefix: "folder/file.txt",
|
||||
status: models.ObjectLegalHoldStatusDisabled,
|
||||
legalHoldFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectLegalHoldOptions) error {
|
||||
legalHoldFunc: func(_ context.Context, _, _ string, _ minio.PutObjectLegalHoldOptions) error {
|
||||
return errors.New("new error")
|
||||
},
|
||||
},
|
||||
@@ -1046,7 +1046,7 @@ func Test_putObjectLegalHold(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
minioPutObjectLegalHoldMock = tt.args.legalHoldFunc
|
||||
err := setObjectLegalHold(ctx, client, tt.args.bucket, tt.args.prefix, tt.args.versionID, tt.args.status)
|
||||
if !reflect.DeepEqual(err, tt.wantError) {
|
||||
@@ -1085,7 +1085,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
GovernanceBypass: false,
|
||||
Mode: models.NewObjectRetentionMode(models.ObjectRetentionModeGovernance),
|
||||
},
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1102,7 +1102,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
GovernanceBypass: false,
|
||||
Mode: models.NewObjectRetentionMode(models.ObjectRetentionModeCompliance),
|
||||
},
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1115,7 +1115,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
versionID: "someversion",
|
||||
prefix: "folder/file.txt",
|
||||
opts: nil,
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1132,7 +1132,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
GovernanceBypass: false,
|
||||
Mode: models.NewObjectRetentionMode(models.ObjectRetentionModeCompliance),
|
||||
},
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1149,7 +1149,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
GovernanceBypass: false,
|
||||
Mode: models.NewObjectRetentionMode(models.ObjectRetentionModeCompliance),
|
||||
},
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1166,7 +1166,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
GovernanceBypass: false,
|
||||
Mode: models.NewObjectRetentionMode(models.ObjectRetentionModeCompliance),
|
||||
},
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return errors.New("new Error")
|
||||
},
|
||||
},
|
||||
@@ -1175,7 +1175,7 @@ func Test_putObjectRetention(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
minioPutObjectRetentionMock = tt.args.retentionFunc
|
||||
err := setObjectRetention(ctx, client, tt.args.bucket, tt.args.prefix, tt.args.versionID, tt.args.opts)
|
||||
if tt.wantError != nil {
|
||||
@@ -1210,7 +1210,7 @@ func Test_deleteObjectRetention(t *testing.T) {
|
||||
bucket: "buck1",
|
||||
versionID: "someversion",
|
||||
prefix: "folder/file.txt",
|
||||
retentionFunc: func(ctx context.Context, bucketName, objectName string, opts minio.PutObjectRetentionOptions) error {
|
||||
retentionFunc: func(_ context.Context, _, _ string, _ minio.PutObjectRetentionOptions) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
@@ -1218,7 +1218,7 @@ func Test_deleteObjectRetention(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
minioPutObjectRetentionMock = tt.args.retentionFunc
|
||||
err := deleteObjectRetention(ctx, client, tt.args.bucket, tt.args.prefix, tt.args.versionID)
|
||||
if tt.wantError != nil {
|
||||
@@ -1252,7 +1252,7 @@ func Test_getObjectInfo(t *testing.T) {
|
||||
args: args{
|
||||
bucketName: "bucket1",
|
||||
prefix: "someprefix",
|
||||
statFunc: func(ctx context.Context, bucketName string, prefix string, opts minio.GetObjectOptions) (minio.ObjectInfo, error) {
|
||||
statFunc: func(_ context.Context, _ string, _ string, _ minio.GetObjectOptions) (minio.ObjectInfo, error) {
|
||||
return minio.ObjectInfo{}, nil
|
||||
},
|
||||
},
|
||||
@@ -1263,7 +1263,7 @@ func Test_getObjectInfo(t *testing.T) {
|
||||
args: args{
|
||||
bucketName: "bucket2",
|
||||
prefix: "someprefi2",
|
||||
statFunc: func(ctx context.Context, bucketName string, prefix string, opts minio.GetObjectOptions) (minio.ObjectInfo, error) {
|
||||
statFunc: func(_ context.Context, _ string, _ string, _ minio.GetObjectOptions) (minio.ObjectInfo, error) {
|
||||
return minio.ObjectInfo{}, errors.New("new Error")
|
||||
},
|
||||
},
|
||||
@@ -1271,7 +1271,7 @@ func Test_getObjectInfo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.test, func(t *testing.T) {
|
||||
t.Run(tt.test, func(_ *testing.T) {
|
||||
minioStatObjectMock = tt.args.statFunc
|
||||
_, err := getObjectInfo(ctx, client, tt.args.bucketName, tt.args.prefix)
|
||||
if tt.wantError != nil {
|
||||
@@ -1312,7 +1312,7 @@ func Test_getScheme(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
gotScheme, gotPath := getScheme(tt.args.rawurl)
|
||||
assert.Equalf(t, tt.wantScheme, gotScheme, "getScheme(%v)", tt.args.rawurl)
|
||||
assert.Equalf(t, tt.wantPath, gotPath, "getScheme(%v)", tt.args.rawurl)
|
||||
@@ -1364,7 +1364,7 @@ func Test_splitSpecial(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, got1 := splitSpecial(tt.args.s, tt.args.delimiter, tt.args.cutdelimiter)
|
||||
assert.Equalf(t, tt.want, got, "splitSpecial(%v, %v, %v)", tt.args.s, tt.args.delimiter, tt.args.cutdelimiter)
|
||||
assert.Equalf(t, tt.want1, got1, "splitSpecial(%v, %v, %v)", tt.args.s, tt.args.delimiter, tt.args.cutdelimiter)
|
||||
@@ -1397,7 +1397,7 @@ func Test_getHost(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.wantHost, getHost(tt.args.authority), "getHost(%v)", tt.args.authority)
|
||||
})
|
||||
}
|
||||
@@ -1439,7 +1439,7 @@ func Test_newClientURL(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, *newClientURL(tt.args.urlStr), "newClientURL(%v)", tt.args.urlStr)
|
||||
})
|
||||
}
|
||||
@@ -1498,7 +1498,7 @@ func Test_getMultipleFilesDownloadResponse(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, got1 := getMultipleFilesDownloadResponse(tt.args.session, tt.args.params)
|
||||
assert.Equal(t, tt.want1, got1)
|
||||
assert.NotNil(t, got)
|
||||
|
||||
@@ -71,7 +71,7 @@ func Test_getSessionResponse(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.preFunc != nil {
|
||||
tt.preFunc()
|
||||
}
|
||||
@@ -128,7 +128,7 @@ func Test_getListOfEnabledFeatures(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.preFunc != nil {
|
||||
tt.preFunc()
|
||||
}
|
||||
|
||||
@@ -166,7 +166,6 @@ func configureCallHomeDiagnostics(ctx context.Context, client MinioAdmin, diagSt
|
||||
}
|
||||
configStr := "callhome enable=" + enableStr
|
||||
_, err = client.setConfigKV(ctx, configStr)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -205,13 +204,11 @@ func setCallHomeConfiguration(ctx context.Context, client MinioAdmin, diagState,
|
||||
}
|
||||
|
||||
err = configureCallHomeDiagnostics(ctx, client, diagState)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = configureCallHomeLogs(ctx, client, logsState, apiKey)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("feature is not supported")
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -69,7 +69,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -79,7 +79,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "callhome",
|
||||
Description: "enable callhome for the cluster",
|
||||
@@ -90,7 +90,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`callhome:_ frequency=24h enable=on`), nil
|
||||
},
|
||||
want: &models.CallHomeGetResponse{
|
||||
@@ -104,7 +104,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -114,7 +114,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "callhome",
|
||||
Description: "enable callhome for the cluster",
|
||||
@@ -125,7 +125,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`callhome:_ frequency=24h enable=off`), nil
|
||||
},
|
||||
want: &models.CallHomeGetResponse{
|
||||
@@ -136,7 +136,7 @@ func Test_getCallHomeRule(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
minioGetConfigKVMock = tt.getConfigKV
|
||||
@@ -181,13 +181,13 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("feature is not supported")
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -195,7 +195,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
KeysHelp: madmin.HelpKVS{},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
setConfigEnv: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -208,7 +208,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
@@ -220,10 +220,10 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key= proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -233,7 +233,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
setConfigEnv: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -246,7 +246,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
session: nil,
|
||||
diagState: true,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
@@ -258,10 +258,10 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -271,7 +271,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
setConfigEnv: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -284,7 +284,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
@@ -296,10 +296,10 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -309,7 +309,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
setConfigEnv: func(_ string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
@@ -322,7 +322,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKV: func(_, _ string, _ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
@@ -334,10 +334,10 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
getConfigKV: func(_ string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
helpConfigKVGlobal: func(_ bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
@@ -347,7 +347,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
setConfigEnv: func(_ string) (restart bool, err error) {
|
||||
return false, errors.New("new error detected")
|
||||
},
|
||||
wantErr: true,
|
||||
@@ -356,7 +356,7 @@ func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
minioGetConfigKVMock = tt.getConfigKV
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestWatch(t *testing.T) {
|
||||
|
||||
// Test-1: Serve Watch with no errors until Watch finishes sending
|
||||
// define mock function behavior
|
||||
mcWatchMock = func(ctx context.Context, params mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
mcWatchMock = func(_ context.Context, _ mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
wo := &mc.WatchObject{
|
||||
EventInfoChan: make(chan []mc.EventInfo),
|
||||
ErrorChan: make(chan *probe.Error),
|
||||
@@ -109,7 +109,7 @@ func TestWatch(t *testing.T) {
|
||||
}
|
||||
writesCount := 1
|
||||
// mock connection WriteMessage() no error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, data []byte) error {
|
||||
// emulate that receiver gets the message written
|
||||
var t []mc.EventInfo
|
||||
_ = json.Unmarshal(data, &t)
|
||||
@@ -136,7 +136,7 @@ func TestWatch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-2: if error happens while writing, return error
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return fmt.Errorf("error on write")
|
||||
}
|
||||
if err := startWatch(ctx, mockWSConn, client, testOptions); assert.Error(err) {
|
||||
@@ -145,7 +145,7 @@ func TestWatch(t *testing.T) {
|
||||
|
||||
// Test-3: error happens on Watch, watch should stop
|
||||
// and error shall be returned.
|
||||
mcWatchMock = func(ctx context.Context, params mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
mcWatchMock = func(_ context.Context, _ mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
wo := &mc.WatchObject{
|
||||
EventInfoChan: make(chan []mc.EventInfo),
|
||||
ErrorChan: make(chan *probe.Error),
|
||||
@@ -171,7 +171,7 @@ func TestWatch(t *testing.T) {
|
||||
}(wo)
|
||||
return wo, nil
|
||||
}
|
||||
connWriteMessageMock = func(messageType int, data []byte) error {
|
||||
connWriteMessageMock = func(_ int, _ []byte) error {
|
||||
return nil
|
||||
}
|
||||
if err := startWatch(ctx, mockWSConn, client, testOptions); assert.Error(err) {
|
||||
@@ -180,7 +180,7 @@ func TestWatch(t *testing.T) {
|
||||
|
||||
// Test-4: error happens on Watch, watch should stop
|
||||
// and error shall be returned.
|
||||
mcWatchMock = func(ctx context.Context, params mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
mcWatchMock = func(_ context.Context, _ mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
return nil, &probe.Error{Cause: fmt.Errorf("error on watch")}
|
||||
}
|
||||
if err := startWatch(ctx, mockWSConn, client, testOptions); assert.Error(err) {
|
||||
@@ -188,7 +188,7 @@ func TestWatch(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test-5: return nil on error on watch
|
||||
mcWatchMock = func(ctx context.Context, params mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
mcWatchMock = func(_ context.Context, _ mc.WatchOptions) (*mc.WatchObject, *probe.Error) {
|
||||
wo := &mc.WatchObject{
|
||||
EventInfoChan: make(chan []mc.EventInfo),
|
||||
ErrorChan: make(chan *probe.Error),
|
||||
|
||||
@@ -200,7 +200,6 @@ func ValidateEncodedStyles(encodedStyles string) error {
|
||||
var styleElements *CustomStyles
|
||||
|
||||
err = json.Unmarshal(str, &styleElements)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestRandomCharStringWithAlphabet(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, RandomCharStringWithAlphabet(tt.args.n, tt.args.alphabet), "RandomCharStringWithAlphabet(%v, %v)", tt.args.n, tt.args.alphabet)
|
||||
})
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func TestNewSessionCookieForConsole(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got := NewSessionCookieForConsole(tt.args.token)
|
||||
assert.Equalf(t, tt.want.Value, got.Value, "NewSessionCookieForConsole(%v)", tt.args.token)
|
||||
assert.Equalf(t, tt.want.Path, got.Path, "NewSessionCookieForConsole(%v)", tt.args.token)
|
||||
@@ -144,7 +144,7 @@ func TestExpireSessionCookie(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got := ExpireSessionCookie()
|
||||
assert.Equalf(t, tt.want.Name, got.Name, "ExpireSessionCookie()")
|
||||
assert.Equalf(t, tt.want.Value, got.Value, "ExpireSessionCookie()")
|
||||
@@ -178,7 +178,7 @@ func TestSanitizeEncodedPrefix(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, SanitizeEncodedPrefix(tt.args.rawPrefix), "SanitizeEncodedPrefix(%v)", tt.args.rawPrefix)
|
||||
})
|
||||
}
|
||||
@@ -209,7 +209,7 @@ func Test_isSafeToPreview(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, isSafeToPreview(tt.args.str), "isSafeToPreview(%v)", tt.args.str)
|
||||
})
|
||||
}
|
||||
@@ -239,7 +239,7 @@ func TestRandomCharString(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.wantLength, len(RandomCharString(tt.args.n)), "RandomCharString(%v)", tt.args.n)
|
||||
})
|
||||
}
|
||||
@@ -284,7 +284,7 @@ func TestValidateEncodedStyles(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.wantErr {
|
||||
assert.NotNilf(t, ValidateEncodedStyles(tt.args.encodedStyles), "Wanted an error")
|
||||
} else {
|
||||
@@ -312,7 +312,7 @@ func TestSanitizeEncodedPrefix1(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
assert.Equalf(t, tt.want, SanitizeEncodedPrefix(tt.args.rawPrefix), "SanitizeEncodedPrefix(%v)", tt.args.rawPrefix)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func serveWS(w http.ResponseWriter, req *http.Request) {
|
||||
// can't validate the proper Origin since we don't know the source domain, so we are going
|
||||
// to allow the connection to be upgraded in this case.
|
||||
if getSubPath() != "/" || getConsoleDevMode() {
|
||||
upgrader.CheckOrigin = func(r *http.Request) bool {
|
||||
upgrader.CheckOrigin = func(_ *http.Request) bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,6 @@ func (wsc *wsMinioClient) objectManager(session *models.Principal) {
|
||||
}
|
||||
|
||||
err = wsc.conn.writeMessage(websocket.TextMessage, jsonData)
|
||||
|
||||
if err != nil {
|
||||
LogInfo("Error while writing the message", err)
|
||||
return
|
||||
|
||||
@@ -105,7 +105,7 @@ func newApp(name string) *cli.App {
|
||||
app.Commands = commands
|
||||
app.HideHelpCommand = true // Hide `help, h` command, we already have `minio --help`.
|
||||
app.CustomAppHelpTemplate = consoleHelpTemplate
|
||||
app.CommandNotFound = func(ctx *cli.Context, command string) {
|
||||
app.CommandNotFound = func(_ *cli.Context, command string) {
|
||||
console.Printf("‘%s’ is not a console sub-command. See ‘console --help’.\n", command)
|
||||
closestCommands := findClosestCommands(command)
|
||||
if len(closestCommands) > 0 {
|
||||
|
||||
@@ -77,7 +77,7 @@ func Test_AddAccessRuleAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func Test_GetAccessRulesAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -184,7 +184,7 @@ func Test_DeleteAccessRuleAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func Test_ConfigAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
request, err := http.NewRequest("GET", "http://localhost:9090/api/v1/configs", nil)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -99,7 +99,7 @@ func Test_GetConfigAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func Test_SetConfigAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func Test_ResetConfigAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func Test_AddGroupAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func Test_GetGroupAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func Test_ListGroupsAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -244,7 +244,7 @@ func Test_PutGroupsAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func Test_DeleteGroupAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestInspect(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
resp, err := Inspect(tt.args.volume, tt.args.file, tt.args.encrypt)
|
||||
if tt.expectedError {
|
||||
assert.Nil(err)
|
||||
|
||||
@@ -51,7 +51,6 @@ func TestObjectGet(t *testing.T) {
|
||||
}
|
||||
bucketName := fmt.Sprintf("testbucket-%d", rand.Intn(1000-1)+1)
|
||||
err = minioClient.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1", ObjectLocking: true})
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@@ -128,7 +127,7 @@ func TestObjectGet(t *testing.T) {
|
||||
encodedPrefix: base64.StdEncoding.EncodeToString([]byte("myobject.jpg")),
|
||||
bytesRange: "bytes=9-12",
|
||||
},
|
||||
expectedStatus: 400,
|
||||
expectedStatus: 500,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
@@ -146,7 +145,7 @@ func TestObjectGet(t *testing.T) {
|
||||
encodedPrefix: base64.StdEncoding.EncodeToString([]byte("myobject.jpg")),
|
||||
bytesRange: "bytes=12-16",
|
||||
},
|
||||
expectedStatus: 400,
|
||||
expectedStatus: 500,
|
||||
expectedError: nil,
|
||||
},
|
||||
{
|
||||
@@ -163,13 +162,13 @@ func TestObjectGet(t *testing.T) {
|
||||
encodedPrefix: base64.StdEncoding.EncodeToString([]byte("myobject")),
|
||||
versionID: "garble",
|
||||
},
|
||||
expectedStatus: 400,
|
||||
expectedStatus: 500,
|
||||
expectedError: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -264,7 +263,7 @@ func TestDownloadMultipleFiles(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
resp, err := downloadMultipleFiles(tt.args.bucketName, tt.args.objectLis)
|
||||
if tt.expectedError {
|
||||
assert.Nil(err)
|
||||
|
||||
@@ -182,7 +182,7 @@ func Test_AddPolicyAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -296,7 +296,7 @@ func Test_SetPolicyAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -408,7 +408,7 @@ func Test_SetPolicyMultipleAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -463,7 +463,7 @@ func Test_ListPoliciesAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -536,7 +536,7 @@ func Test_GetPolicyAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -611,7 +611,7 @@ func Test_PolicyListUsersAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -690,7 +690,7 @@ func Test_PolicyListGroupsAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -769,7 +769,7 @@ func Test_DeletePolicyAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -837,7 +837,7 @@ func Test_GetAUserPolicyAPI(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestStartProfiling(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
files := map[string]bool{
|
||||
"profile-127.0.0.1:9000-goroutines.txt": false,
|
||||
"profile-127.0.0.1:9000-goroutines-before.txt": false,
|
||||
|
||||
@@ -183,7 +183,7 @@ func Test_ServiceAccountsAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
@@ -290,7 +290,7 @@ func TestCreateServiceAccountForUserWithCredentials(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 2. Create the service account for the user
|
||||
createServiceAccountWithCredentialsResponse,
|
||||
createServiceAccountWithCredentialsError := CreateServiceAccountForUserWithCredentials(
|
||||
|
||||
@@ -816,7 +816,7 @@ func TestPutObjectsLegalholdStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 3. Put Objects Legal Status
|
||||
putResponse, putError := PutObjectsLegalholdStatus(
|
||||
bucketName,
|
||||
@@ -895,7 +895,7 @@ func TestGetBucketQuota(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
restResp, restErr := GetBucketQuota(
|
||||
tt.args.bucketName,
|
||||
)
|
||||
@@ -951,7 +951,7 @@ func TestPutBucketQuota(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
restResp, restErr := PutBucketQuota(
|
||||
tt.args.bucketName,
|
||||
true, // enabled
|
||||
@@ -1010,7 +1010,7 @@ func TestListBucketEvents(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
restResp, restErr := ListBucketEvents(
|
||||
tt.args.bucketName,
|
||||
)
|
||||
@@ -1118,7 +1118,7 @@ func TestDeleteObjectsRetentionStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 4. Delete Objects Retention Status
|
||||
putResponse, putError := DeleteObjectsRetentionStatus(
|
||||
bucketName,
|
||||
@@ -1175,7 +1175,7 @@ func TestBucketSetPolicy(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// Set Policy
|
||||
restResp, restErr := BucketSetPolicy(
|
||||
tt.args.bucketName,
|
||||
@@ -1265,7 +1265,7 @@ func TestRestoreObjectToASelectedVersion(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 4. Restore Object to a selected version
|
||||
restResp, restErr := RestoreObjectToASelectedVersion(
|
||||
bucketName,
|
||||
@@ -1323,7 +1323,7 @@ func TestPutBucketsTags(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 2. Add a tag to the bucket
|
||||
tags := make(map[string]string)
|
||||
tags["tag2"] = "tag2"
|
||||
@@ -1396,7 +1396,7 @@ func TestGetsTheMetadataOfAnObject(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 3. Get the metadata from an object
|
||||
getRsp, getErr := GetsTheMetadataOfAnObject(
|
||||
bucketName, tt.args.prefix)
|
||||
@@ -1482,7 +1482,7 @@ func TestPutObjectsRetentionStatus(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 3. Put Objects Legal Status
|
||||
putResponse, putError := PutObjectsRetentionStatus(
|
||||
bucketName,
|
||||
@@ -1565,7 +1565,7 @@ func TestShareObjectOnURL(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// 3. Share the object on a URL
|
||||
shareResponse, shareError := SharesAnObjectOnAUrl(bucketName, tt.args.prefix, versionID, "604800s")
|
||||
assert.Nil(shareError)
|
||||
@@ -2138,7 +2138,7 @@ func TestDeleteBucket(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
// Create bucket if needed for the test
|
||||
if tt.args.createBucketName != "" {
|
||||
if err := minioClient.MakeBucket(context.Background(), tt.args.createBucketName, minio.MakeBucketOptions{}); err != nil {
|
||||
@@ -2464,7 +2464,7 @@ func TestAddBucket(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if !setupBucket(tt.args.bucketName, false, nil, nil, nil, assert, tt.expectedStatus) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -893,7 +893,7 @@ func Test_GetUserPolicyAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
client := &http.Client{
|
||||
Timeout: 3 * time.Second,
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestGenerateLoginURL(t *testing.T) {
|
||||
oauth2Config: Oauth2configMock{},
|
||||
}
|
||||
// Test-1 : GenerateLoginURL() generates URL correctly with provided state
|
||||
oauth2ConfigAuthCodeURLMock = func(state string, opts ...oauth2.AuthCodeOption) string {
|
||||
oauth2ConfigAuthCodeURLMock = func(state string, _ ...oauth2.AuthCodeOption) string {
|
||||
// Internally we are testing the private method getRandomStateWithHMAC, this function should always returns
|
||||
// a non-empty string
|
||||
return state
|
||||
|
||||
@@ -174,7 +174,7 @@ func TestInitializeLogger(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.setEnvVars != nil {
|
||||
tt.setEnvVars()
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func TestEnableJSON(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
EnableJSON()
|
||||
if !IsJSON() {
|
||||
t.Errorf("EnableJSON() = %v, want %v", IsJSON(), true)
|
||||
@@ -215,7 +215,7 @@ func TestEnableQuiet(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
EnableQuiet()
|
||||
if !IsQuiet() {
|
||||
t.Errorf("EnableQuiet() = %v, want %v", IsQuiet(), true)
|
||||
@@ -233,7 +233,7 @@ func TestEnableAnonymous(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
EnableAnonymous()
|
||||
if !IsAnonymous() {
|
||||
t.Errorf("EnableAnonymous() = %v, want %v", IsAnonymous(), true)
|
||||
|
||||
@@ -43,7 +43,7 @@ func TestNewEntry(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := NewEntry(tt.args.deploymentID); got.DeploymentID != tt.want.DeploymentID {
|
||||
t.Errorf("NewEntry() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func TestNewEntry(t *testing.T) {
|
||||
// },
|
||||
// }
|
||||
// for _, tt := range tests {
|
||||
// t.Run(tt.name, func(t *testing.T) {
|
||||
// t.Run(tt.name, func(_ *testing.T) {
|
||||
// if tt.preFunc != nil {
|
||||
// tt.preFunc()
|
||||
// }
|
||||
|
||||
@@ -52,7 +52,7 @@ func Test_subnetBaseURL(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if tt.args.env != nil {
|
||||
for k, v := range tt.args.env {
|
||||
os.Setenv(k, v)
|
||||
@@ -102,7 +102,7 @@ func Test_subnetRegisterURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetRegisterURL(); got != tt.want {
|
||||
t.Errorf("subnetRegisterURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func Test_subnetLoginURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetLoginURL(); got != tt.want {
|
||||
t.Errorf("subnetLoginURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func Test_subnetOrgsURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetOrgsURL(); got != tt.want {
|
||||
t.Errorf("subnetOrgsURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -237,7 +237,7 @@ func Test_subnetMFAURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetMFAURL(); got != tt.want {
|
||||
t.Errorf("subnetMFAURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ func Test_subnetAPIKeyURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetAPIKeyURL(); got != tt.want {
|
||||
t.Errorf("subnetAPIKeyURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -327,7 +327,7 @@ func TestLogWebhookURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := LogWebhookURL(); got != tt.want {
|
||||
t.Errorf("LogWebhookURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -378,7 +378,7 @@ func TestUploadURL(t *testing.T) {
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := UploadURL(tt.args.uploadType, tt.args.filename); got != tt.want {
|
||||
t.Errorf("UploadURL() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -409,7 +409,7 @@ func TestUploadAuthHeaders(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := UploadAuthHeaders(tt.args.apiKey); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("UploadAuthHeaders() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -442,7 +442,7 @@ func TestGenerateRegToken(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, err := GenerateRegToken(tt.args.clusterRegInfo)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("GenerateRegToken() error = %v, wantErr %v", err, tt.wantErr)
|
||||
@@ -473,7 +473,7 @@ func Test_subnetAuthHeaders(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := subnetAuthHeaders(tt.args.authToken); !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("subnetAuthHeaders() = %v, want %v", got, tt.want)
|
||||
}
|
||||
@@ -594,7 +594,7 @@ func Test_getDriveSpaceInfo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, got1 := getDriveSpaceInfo(tt.args.admInfo)
|
||||
if got != tt.want {
|
||||
t.Errorf("getDriveSpaceInfo() got = %v, want %v", got, tt.want)
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestGetDivisibleSize(t *testing.T) {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
t.Run("", func(_ *testing.T) {
|
||||
gotGCD := getDivisibleSize(testCase.totalSizes)
|
||||
if testCase.result != gotGCD {
|
||||
t.Errorf("Expected %v, got %v", testCase.result, gotGCD)
|
||||
@@ -143,7 +143,7 @@ func TestGetSetIndexes(t *testing.T) {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
t.Run("", func(_ *testing.T) {
|
||||
argPatterns := make([]ellipses.ArgPattern, len(testCase.args))
|
||||
for i, arg := range testCase.args {
|
||||
patterns, err := ellipses.FindEllipsesPatterns(arg)
|
||||
@@ -277,7 +277,7 @@ func TestPossibleParities(t *testing.T) {
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run("", func(t *testing.T) {
|
||||
t.Run("", func(_ *testing.T) {
|
||||
gotPs, err := PossibleParityValues(testCase.arg)
|
||||
if err != nil && testCase.success {
|
||||
t.Errorf("Expected success but failed instead %s", err)
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestDecodeInput(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
got, err := DecodeBase64(tt.args.s)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DecodeBase64() error = %v, wantErr %v", err, tt.wantErr)
|
||||
@@ -119,7 +119,7 @@ func TestClientIPFromContext(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
if got := ClientIPFromContext(tt.args.ctx); got != tt.want {
|
||||
t.Errorf("ClientIPFromContext() = %v, want %v", got, tt.want)
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ func TestAddSiteReplicationInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
actualStatusCode, err := AddSiteReplicationInfo(tt.args.sites)
|
||||
fmt.Println("TestAddSiteReplicationInfo: ", actualStatusCode)
|
||||
|
||||
@@ -269,7 +269,7 @@ func TestEditSiteReplicationInfo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
actualStatusCode, err := EditSiteReplicationInfo(tt.args)
|
||||
fmt.Println("TestEditSiteReplicationInfo: ", actualStatusCode)
|
||||
if tt.expStatusCode > 0 {
|
||||
@@ -331,7 +331,7 @@ func TestDeleteSiteReplicationInfo(t *testing.T) {
|
||||
}
|
||||
fmt.Println("Delete Site Replication")
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
actualStatusCode, err := DeleteSiteReplicationInfo(tt.args)
|
||||
fmt.Println("TestDeleteSiteReplicationInfo: ", actualStatusCode)
|
||||
if tt.expStatusCode > 0 {
|
||||
@@ -440,7 +440,7 @@ func TestGetSiteReplicationStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
for ti, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Run(tt.name, func(_ *testing.T) {
|
||||
response, err := makeStatusExecuteReq("GET", tt.args)
|
||||
tgt := &models.SiteReplicationStatusResponse{}
|
||||
json.NewDecoder(response.Body).Decode(tgt)
|
||||
|
||||
@@ -135,7 +135,6 @@ func TestMain(t *testing.T) {
|
||||
fmt.Println(body)
|
||||
|
||||
err = json.Unmarshal(body, &jsonMap)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error JSON Unmarshal %s\n", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user