[#85] pool: fix skipped tests

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-25 11:34:09 +03:00 committed by LeL
parent e56eef495d
commit aa6a4950d5
3 changed files with 270 additions and 258 deletions

View file

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT. // Code generated by MockGen. DO NOT EDIT.
// Source: github.com/nspcc-dev/neofs-sdk-go/Pool (interfaces: client) // Source: github.com/nspcc-dev/neofs-sdk-go/pool (interfaces: Client)
// Package pool is a generated GoMock package. // Package pool is a generated GoMock package.
package pool package pool
@ -9,10 +9,16 @@ import (
reflect "reflect" reflect "reflect"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
client0 "github.com/nspcc-dev/neofs-sdk-go/client" accounting "github.com/nspcc-dev/neofs-sdk-go/accounting"
container "github.com/nspcc-dev/neofs-sdk-go/container"
id "github.com/nspcc-dev/neofs-sdk-go/container/id"
eacl "github.com/nspcc-dev/neofs-sdk-go/eacl"
netmap "github.com/nspcc-dev/neofs-sdk-go/netmap"
object "github.com/nspcc-dev/neofs-sdk-go/object"
id0 "github.com/nspcc-dev/neofs-sdk-go/object/id"
) )
// MockClient is a mock of client interface. // MockClient is a mock of Client interface.
type MockClient struct { type MockClient struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockClientMockRecorder recorder *MockClientMockRecorder
@ -35,79 +41,114 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder {
return m.recorder return m.recorder
} }
// CreateSession mocks base method. // BalanceGet mocks base method.
func (m *MockClient) SessionCreate(arg0 context.Context, arg1 client0.PrmSessionCreate) (*client0.ResSessionCreate, error) { func (m *MockClient) BalanceGet(arg0 context.Context, arg1 PrmBalanceGet) (*accounting.Decimal, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "BalanceGet", arg0, arg1)
ret := m.ctrl.Call(m, "SessionCreate", varargs...) ret0, _ := ret[0].(*accounting.Decimal)
ret0, _ := ret[0].(*client0.ResSessionCreate)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// CreateSession indicates an expected call of CreateSession. // BalanceGet indicates an expected call of BalanceGet.
func (mr *MockClientMockRecorder) CreateSession(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) BalanceGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BalanceGet", reflect.TypeOf((*MockClient)(nil).BalanceGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SessionCreate", reflect.TypeOf((*MockClient)(nil).SessionCreate), varargs...)
} }
// DeleteContainer mocks base method. // ContainerDelete mocks base method.
func (m *MockClient) ContainerDelete(arg0 context.Context, arg1 client0.PrmContainerDelete) (*client0.ResContainerDelete, error) { func (m *MockClient) ContainerDelete(arg0 context.Context, arg1 PrmContainerDelete) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "ContainerDelete", arg0, arg1)
ret := m.ctrl.Call(m, "ContainerDelete", varargs...) ret0, _ := ret[0].(error)
ret0, _ := ret[0].(*client0.ResContainerDelete) return ret0
}
// ContainerDelete indicates an expected call of ContainerDelete.
func (mr *MockClientMockRecorder) ContainerDelete(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerDelete", reflect.TypeOf((*MockClient)(nil).ContainerDelete), arg0, arg1)
}
// ContainerEACL mocks base method.
func (m *MockClient) ContainerEACL(arg0 context.Context, arg1 PrmContainerEACL) (*eacl.Table, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerEACL", arg0, arg1)
ret0, _ := ret[0].(*eacl.Table)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// DeleteContainer indicates an expected call of DeleteContainer. // ContainerEACL indicates an expected call of ContainerEACL.
func (mr *MockClientMockRecorder) DeleteContainer(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ContainerEACL(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerEACL", reflect.TypeOf((*MockClient)(nil).ContainerEACL), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerDelete", reflect.TypeOf((*MockClient)(nil).ContainerDelete), varargs...)
} }
// ObjectDelete mocks base method. // ContainerGet mocks base method.
func (m *MockClient) ObjectDelete(arg0 context.Context, arg1 client0.PrmObjectDelete) (*client0.ResObjectDelete, error) { func (m *MockClient) ContainerGet(arg0 context.Context, arg1 PrmContainerGet) (*container.Container, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectDelete", arg0, arg1) ret := m.ctrl.Call(m, "ContainerGet", arg0, arg1)
ret0, _ := ret[0].(*client0.ResObjectDelete) ret0, _ := ret[0].(*container.Container)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// DeleteObject indicates an expected call of DeleteObject. // ContainerGet indicates an expected call of ContainerGet.
func (mr *MockClientMockRecorder) DeleteObject(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ContainerGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerGet", reflect.TypeOf((*MockClient)(nil).ContainerGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteObject", reflect.TypeOf((*MockClient)(nil).ObjectDelete), varargs...)
} }
// EACL mocks base method. // ContainerList mocks base method.
func (m *MockClient) ContainerEACL(arg0 context.Context, arg1 client0.PrmContainerEACL) (*client0.ResContainerEACL, error) { func (m *MockClient) ContainerList(arg0 context.Context, arg1 PrmContainerList) ([]id.ID, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "ContainerList", arg0, arg1)
ret := m.ctrl.Call(m, "ContainerEACL", varargs...) ret0, _ := ret[0].([]id.ID)
ret0, _ := ret[0].(*client0.ResContainerEACL)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// EACL indicates an expected call of EACL. // ContainerList indicates an expected call of ContainerList.
func (mr *MockClientMockRecorder) EACL(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ContainerList(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerList", reflect.TypeOf((*MockClient)(nil).ContainerList), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerEACL", reflect.TypeOf((*MockClient)(nil).ContainerEACL), varargs...) }
// ContainerPut mocks base method.
func (m *MockClient) ContainerPut(arg0 context.Context, arg1 PrmContainerPut) (*id.ID, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerPut", arg0, arg1)
ret0, _ := ret[0].(*id.ID)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ContainerPut indicates an expected call of ContainerPut.
func (mr *MockClientMockRecorder) ContainerPut(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerPut", reflect.TypeOf((*MockClient)(nil).ContainerPut), arg0, arg1)
}
// ContainerSetEACL mocks base method.
func (m *MockClient) ContainerSetEACL(arg0 context.Context, arg1 PrmContainerSetEACL) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerSetEACL", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ContainerSetEACL indicates an expected call of ContainerSetEACL.
func (mr *MockClientMockRecorder) ContainerSetEACL(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerSetEACL", reflect.TypeOf((*MockClient)(nil).ContainerSetEACL), arg0, arg1)
} }
// EndpointInfo mocks base method. // EndpointInfo mocks base method.
func (m *MockClient) EndpointInfo(arg0 context.Context, arg1 client0.PrmEndpointInfo) (*client0.ResEndpointInfo, error) { func (m *MockClient) EndpointInfo(arg0 context.Context, arg1 PrmEndpointInfo) (*netmap.NodeInfo, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "EndpointInfo", arg0, arg1)
ret := m.ctrl.Call(m, "EndpointInfo", varargs...) ret0, _ := ret[0].(*netmap.NodeInfo)
ret0, _ := ret[0].(*client0.ResEndpointInfo)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -115,99 +156,14 @@ func (m *MockClient) EndpointInfo(arg0 context.Context, arg1 client0.PrmEndpoint
// EndpointInfo indicates an expected call of EndpointInfo. // EndpointInfo indicates an expected call of EndpointInfo.
func (mr *MockClientMockRecorder) EndpointInfo(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) EndpointInfo(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndpointInfo", reflect.TypeOf((*MockClient)(nil).EndpointInfo), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndpointInfo", reflect.TypeOf((*MockClient)(nil).EndpointInfo), varargs...)
}
// GetBalance mocks base method.
func (m *MockClient) BalanceGet(arg0 context.Context, arg1 client0.PrmBalanceGet) (*client0.ResBalanceGet, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
ret := m.ctrl.Call(m, "BalanceGet", varargs...)
ret0, _ := ret[0].(*client0.ResBalanceGet)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetBalance indicates an expected call of GetBalance.
func (mr *MockClientMockRecorder) GetBalance(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BalanceGet", reflect.TypeOf((*MockClient)(nil).BalanceGet), varargs...)
}
// GetContainer mocks base method.
func (m *MockClient) ContainerGet(arg0 context.Context, arg1 client0.PrmContainerGet) (*client0.ResContainerGet, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
ret := m.ctrl.Call(m, "ContainerGet", varargs...)
ret0, _ := ret[0].(*client0.ResContainerGet)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetContainer indicates an expected call of GetContainer.
func (mr *MockClientMockRecorder) GetContainer(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerGet", reflect.TypeOf((*MockClient)(nil).ContainerGet), varargs...)
}
// ObjectGetInitmocks base method.
func (m *MockClient) ObjectGetInit(arg0 context.Context, arg1 client0.PrmObjectGet) (*client0.ObjectReader, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetObject", arg0, arg1)
ret0, _ := ret[0].(*client0.ObjectReader)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetObject indicates an expected call of GetObject.
func (mr *MockClientMockRecorder) GetObject(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectGetInit", reflect.TypeOf((*MockClient)(nil).ObjectGetInit), varargs...)
}
// ObjectHead mocks base method.
func (m *MockClient) ObjectHead(arg0 context.Context, arg1 client0.PrmObjectHead) (*client0.ResObjectHead, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HeadObject", arg0, arg1)
ret0, _ := ret[0].(*client0.ResObjectHead)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// HeadObject indicates an expected call of HeadObject.
func (mr *MockClientMockRecorder) HeadObject(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeadObject", reflect.TypeOf((*MockClient)(nil).ObjectHead), varargs...)
}
// ListContainers mocks base method.
func (m *MockClient) ContainerList(arg0 context.Context, arg1 client0.PrmContainerList) (*client0.ResContainerList, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
ret := m.ctrl.Call(m, "ContainerList", varargs...)
ret0, _ := ret[0].(*client0.ResContainerList)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListContainers indicates an expected call of ListContainers.
func (mr *MockClientMockRecorder) ListContainers(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerList", reflect.TypeOf((*MockClient)(nil).ContainerList), varargs...)
} }
// NetworkInfo mocks base method. // NetworkInfo mocks base method.
func (m *MockClient) NetworkInfo(arg0 context.Context, arg1 client0.PrmNetworkInfo) (*client0.ResNetworkInfo, error) { func (m *MockClient) NetworkInfo(arg0 context.Context, arg1 PrmNetworkInfo) (*netmap.NetworkInfo, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "NetworkInfo", arg0, arg1)
ret := m.ctrl.Call(m, "NetworkInfo", varargs...) ret0, _ := ret[0].(*netmap.NetworkInfo)
ret0, _ := ret[0].(*client0.ResNetworkInfo)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
@ -215,88 +171,109 @@ func (m *MockClient) NetworkInfo(arg0 context.Context, arg1 client0.PrmNetworkIn
// NetworkInfo indicates an expected call of NetworkInfo. // NetworkInfo indicates an expected call of NetworkInfo.
func (mr *MockClientMockRecorder) NetworkInfo(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) NetworkInfo(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkInfo", reflect.TypeOf((*MockClient)(nil).NetworkInfo), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkInfo", reflect.TypeOf((*MockClient)(nil).NetworkInfo), varargs...)
} }
// ObjectRangeInit mocks base method. // ObjectDelete mocks base method.
func (m *MockClient) ObjectRangeInit(arg0 context.Context, arg1 client0.PrmObjectRange) (*client0.ObjectRangeReader, error) { func (m *MockClient) ObjectDelete(arg0 context.Context, arg1 PrmObjectDelete) error {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectRangeInit", arg0, arg1) ret := m.ctrl.Call(m, "ObjectDelete", arg0, arg1)
ret0, _ := ret[0].(*client0.ObjectRangeReader) ret0, _ := ret[0].(error)
return ret0
}
// ObjectDelete indicates an expected call of ObjectDelete.
func (mr *MockClientMockRecorder) ObjectDelete(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectDelete", reflect.TypeOf((*MockClient)(nil).ObjectDelete), arg0, arg1)
}
// ObjectGet mocks base method.
func (m *MockClient) ObjectGet(arg0 context.Context, arg1 PrmObjectGet) (*ResGetObject, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectGet", arg0, arg1)
ret0, _ := ret[0].(*ResGetObject)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// ObjectRange indicates an expected call of ObjectRangeInit. // ObjectGet indicates an expected call of ObjectGet.
func (mr *MockClientMockRecorder) ObjectRange(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ObjectGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectGet", reflect.TypeOf((*MockClient)(nil).ObjectGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectRangeInit", reflect.TypeOf((*MockClient)(nil).ObjectRangeInit), varargs...)
} }
// PutContainer mocks base method. // ObjectHead mocks base method.
func (m *MockClient) ContainerPut(arg0 context.Context, arg1 client0.PrmContainerPut) (*client0.ResContainerPut, error) { func (m *MockClient) ObjectHead(arg0 context.Context, arg1 PrmObjectHead) (*object.Object, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "ObjectHead", arg0, arg1)
ret := m.ctrl.Call(m, "ContainerPut", varargs...) ret0, _ := ret[0].(*object.Object)
ret0, _ := ret[0].(*client0.ResContainerPut)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// PutContainer indicates an expected call of PutContainer. // ObjectHead indicates an expected call of ObjectHead.
func (mr *MockClientMockRecorder) PutContainer(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ObjectHead(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectHead", reflect.TypeOf((*MockClient)(nil).ObjectHead), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerPut", reflect.TypeOf((*MockClient)(nil).ContainerPut), varargs...)
} }
// ObjectPutInitmocks base method. // ObjectPut mocks base method.
func (m *MockClient) ObjectPutInit(arg0 context.Context, arg1 client0.PrmObjectPutInit) (*client0.ObjectWriter, error) { func (m *MockClient) ObjectPut(arg0 context.Context, arg1 PrmObjectPut) (*id0.ID, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PutObject", arg0) ret := m.ctrl.Call(m, "ObjectPut", arg0, arg1)
ret0, _ := ret[0].(*client0.ObjectWriter) ret0, _ := ret[0].(*id0.ID)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// PutObject indicates an expected call of PutObject. // ObjectPut indicates an expected call of ObjectPut.
func (mr *MockClientMockRecorder) PutObject(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ObjectPut(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectPut", reflect.TypeOf((*MockClient)(nil).ObjectPut), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectPutInit", reflect.TypeOf((*MockClient)(nil).ObjectPutInit), varargs...)
} }
// ObjectSearchInitmocks base method. // ObjectRange mocks base method.
func (m *MockClient) ObjectSearchInit(arg0 context.Context, arg1 client0.PrmObjectSearch) (*client0.ObjectListReader, error) { func (m *MockClient) ObjectRange(arg0 context.Context, arg1 PrmObjectRange) (*ResObjectRange, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectSearchInit", arg0, arg1) ret := m.ctrl.Call(m, "ObjectRange", arg0, arg1)
ret0, _ := ret[0].(*client0.ObjectListReader) ret0, _ := ret[0].(*ResObjectRange)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// SearchObjects indicates an expected call of SearchObjects. // ObjectRange indicates an expected call of ObjectRange.
func (mr *MockClientMockRecorder) SearchObjects(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ObjectRange(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{arg0, arg1}, arg2...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectRange", reflect.TypeOf((*MockClient)(nil).ObjectRange), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SearchObjects", reflect.TypeOf((*MockClient)(nil).ObjectSearchInit), varargs...)
} }
// SetEACL mocks base method. // ObjectSearch mocks base method.
func (m *MockClient) ContainerSetEACL(arg0 context.Context, arg1 client0.PrmContainerSetEACL) (*client0.ResContainerSetEACL, error) { func (m *MockClient) ObjectSearch(arg0 context.Context, arg1 PrmObjectSearch) (*ResObjectSearch, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} ret := m.ctrl.Call(m, "ObjectSearch", arg0, arg1)
ret := m.ctrl.Call(m, "ContainerSetEACL", varargs...) ret0, _ := ret[0].(*ResObjectSearch)
ret0, _ := ret[0].(*client0.ResContainerSetEACL)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }
// SetEACL indicates an expected call of SetEACL. // ObjectSearch indicates an expected call of ObjectSearch.
func (mr *MockClientMockRecorder) SetEACL(arg0, arg1 interface{}) *gomock.Call { func (mr *MockClientMockRecorder) ObjectSearch(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectSearch", reflect.TypeOf((*MockClient)(nil).ObjectSearch), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerSetEACL", reflect.TypeOf((*MockClient)(nil).ContainerSetEACL), varargs...) }
// SessionCreate mocks base method.
func (m *MockClient) SessionCreate(arg0 context.Context, arg1 PrmCreateSession) (*ResCreateSession, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SessionCreate", arg0, arg1)
ret0, _ := ret[0].(*ResCreateSession)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SessionCreate indicates an expected call of SessionCreate.
func (mr *MockClientMockRecorder) SessionCreate(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SessionCreate", reflect.TypeOf((*MockClient)(nil).SessionCreate), arg0, arg1)
} }

View file

@ -1,8 +1,10 @@
package pool package pool
// To generate mock define 'type Client client' in pool.go
//go:generate mockgen -destination mock_test.go -package pool . Client //go:generate mockgen -destination mock_test.go -package pool . Client
import ( import (
"bytes"
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"fmt" "fmt"
@ -13,7 +15,7 @@ import (
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
sdkClient "github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/container"
"github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
"github.com/nspcc-dev/neofs-sdk-go/object/address" "github.com/nspcc-dev/neofs-sdk-go/object/address"
@ -49,9 +51,9 @@ func TestBuildPoolCreateSessionFailed(t *testing.T) {
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error session")).AnyTimes() mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error session")).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResEndpointInfo{}, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil return mockClient, nil
} }
@ -74,8 +76,6 @@ func newPrivateKey(t *testing.T) *ecdsa.PrivateKey {
} }
func TestBuildPoolOneNodeFailed(t *testing.T) { func TestBuildPoolOneNodeFailed(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
ctrl2 := gomock.NewController(t) ctrl2 := gomock.NewController(t)
@ -88,22 +88,25 @@ func TestBuildPoolOneNodeFailed(t *testing.T) {
clientCount++ clientCount++
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockInvokes := 0 mockInvokes := 0
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*ResCreateSession, error) {
mockInvokes++ mockInvokes++
if mockInvokes == 1 { if mockInvokes == 1 {
expectedToken = newToken(t) expectedToken = newToken(t)
return nil, fmt.Errorf("error session") return nil, fmt.Errorf("error session")
} }
return expectedToken, nil return &ResCreateSession{
sessionKey: expectedToken.SessionKey(),
id: expectedToken.ID(),
}, nil
}).AnyTimes() }).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2) mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
if clientCount == 0 { if clientCount == 0 {
return mockClient, nil return mockClient, nil
@ -136,7 +139,7 @@ func TestBuildPoolOneNodeFailed(t *testing.T) {
return false return false
} }
st := clientPool.cache.Get(formCacheKey(cp.address, clientPool.key)) st := clientPool.cache.Get(formCacheKey(cp.address, clientPool.key))
return st == expectedToken return areEqualTokens(st, expectedToken)
} }
require.Never(t, condition, 900*time.Millisecond, 100*time.Millisecond) require.Never(t, condition, 900*time.Millisecond, 100*time.Millisecond)
require.Eventually(t, condition, 3*time.Second, 300*time.Millisecond) require.Eventually(t, condition, 3*time.Second, 300*time.Millisecond)
@ -151,8 +154,6 @@ func TestBuildPoolZeroNodes(t *testing.T) {
} }
func TestOneNode(t *testing.T) { func TestOneNode(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
tok := session.NewToken() tok := session.NewToken()
@ -160,11 +161,16 @@ func TestOneNode(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
tok.SetID(uid) tok.SetID(uid)
tokRes := &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(tok, nil) mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(tokRes, nil)
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResEndpointInfo{}, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil return mockClient, nil
} }
@ -183,27 +189,36 @@ func TestOneNode(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Equal(t, tok, st) require.True(t, areEqualTokens(tok, st))
}
func areEqualTokens(t1, t2 *session.Token) bool {
if t1 == nil || t2 == nil {
return false
}
return bytes.Equal(t1.ID(), t2.ID()) &&
bytes.Equal(t1.SessionKey(), t2.SessionKey())
} }
func TestTwoNodes(t *testing.T) { func TestTwoNodes(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
var tokens []*session.Token var tokens []*session.Token
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := session.NewToken() tok := session.NewToken()
uid, err := uuid.New().MarshalBinary() uid, err := uuid.New().MarshalBinary()
require.NoError(t, err) require.NoError(t, err)
tok.SetID(uid) tok.SetID(uid)
tokens = append(tokens, tok) tokens = append(tokens, tok)
return tok, err return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
}) })
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResEndpointInfo{}, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil return mockClient, nil
} }
@ -225,12 +240,19 @@ func TestTwoNodes(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Contains(t, tokens, st) require.True(t, containsTokens(tokens, st))
}
func containsTokens(list []*session.Token, item *session.Token) bool {
for _, tok := range list {
if areEqualTokens(tok, item) {
return true
}
}
return false
} }
func TestOneOfTwoFailed(t *testing.T) { func TestOneOfTwoFailed(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
ctrl2 := gomock.NewController(t) ctrl2 := gomock.NewController(t)
@ -239,24 +261,30 @@ func TestOneOfTwoFailed(t *testing.T) {
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
clientCount++ clientCount++
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := newToken(t) tok := newToken(t)
tokens = append(tokens, tok) tokens = append(tokens, tok)
return tok, nil return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes() }).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2) mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := newToken(t) tok := newToken(t)
tokens = append(tokens, tok) tokens = append(tokens, tok)
return tok, nil return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes() }).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*sdkClient.ResEndpointInfo, error) { mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NodeInfo, error) {
return nil, fmt.Errorf("error") return nil, fmt.Errorf("error")
}).AnyTimes() }).AnyTimes()
mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*sdkClient.ResNetworkInfo, error) { mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NetworkInfo, error) {
return nil, fmt.Errorf("error") return nil, fmt.Errorf("error")
}).AnyTimes() }).AnyTimes()
@ -290,20 +318,18 @@ func TestOneOfTwoFailed(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Equal(t, tokens[0], st) require.True(t, areEqualTokens(tokens[0], st))
} }
} }
func TestTwoFailed(t *testing.T) { func TestTwoFailed(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil return mockClient, nil
} }
@ -332,24 +358,26 @@ func TestTwoFailed(t *testing.T) {
} }
func TestSessionCache(t *testing.T) { func TestSessionCache(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
var tokens []*session.Token var tokens []*session.Token
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*ResCreateSession, error) {
tok := session.NewToken() tok := session.NewToken()
uid, err := uuid.New().MarshalBinary() uid, err := uuid.New().MarshalBinary()
require.NoError(t, err) require.NoError(t, err)
tok.SetID(uid) tok.SetID(uid)
tokens = append(tokens, tok) tokens = append(tokens, tok)
return tok, err return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
}).MaxTimes(3) }).MaxTimes(3)
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("session token does not exist")) mockClient.EXPECT().ObjectGet(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("session token does not exist"))
mockClient.EXPECT().PutObject(gomock.Any(), gomock.Any()).Return(nil, nil) mockClient.EXPECT().ObjectPut(gomock.Any(), gomock.Any()).Return(nil, nil)
return mockClient, nil return mockClient, nil
} }
@ -376,10 +404,11 @@ func TestSessionCache(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Contains(t, tokens, st) require.True(t, containsTokens(tokens, st))
var prm PrmObjectGet var prm PrmObjectGet
prm.SetAddress(address.Address{}) prm.SetAddress(address.Address{})
prm.UseSession(*session.NewToken())
_, err = pool.GetObject(ctx, prm) _, err = pool.GetObject(ctx, prm)
require.Error(t, err) require.Error(t, err)
@ -400,38 +429,40 @@ func TestSessionCache(t *testing.T) {
cp, err = pool.connection() cp, err = pool.connection()
require.NoError(t, err) require.NoError(t, err)
st = pool.cache.Get(formCacheKey(cp.address, pool.key)) st = pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Contains(t, tokens, st) require.True(t, containsTokens(tokens, st))
} }
func TestPriority(t *testing.T) { func TestPriority(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
ctrl2 := gomock.NewController(t) ctrl2 := gomock.NewController(t)
var tokens []*session.Token tokens := make([]*session.Token, 2)
clientCount := -1 clientBuilder := func(endpoint string) (client, error) {
clientBuilder := func(_ string) (client, error) {
clientCount++
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := newToken(t) tok := newToken(t)
tokens = append(tokens, tok) tokens[0] = tok
return tok, nil return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes() }).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2) mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := newToken(t) tok := newToken(t)
tokens = append(tokens, tok) tokens[1] = tok
return tok, nil return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes() }).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
if clientCount == 0 { if endpoint == "peer0" {
return mockClient, nil return mockClient, nil
} }
return mockClient2, nil return mockClient2, nil
@ -460,13 +491,13 @@ func TestPriority(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
return st == tokens[0] return areEqualTokens(st, tokens[0])
} }
secondNode := func() bool { secondNode := func() bool {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
return st == tokens[1] return areEqualTokens(st, tokens[1])
} }
require.Never(t, secondNode, time.Second, 200*time.Millisecond) require.Never(t, secondNode, time.Second, 200*time.Millisecond)
@ -475,23 +506,25 @@ func TestPriority(t *testing.T) {
} }
func TestSessionCacheWithKey(t *testing.T) { func TestSessionCacheWithKey(t *testing.T) {
t.Skip("NeoFS API client can't be mocked") // neofs-sdk-go#85
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
var tokens []*session.Token var tokens []*session.Token
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*session.Token, error) { mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
tok := session.NewToken() tok := session.NewToken()
uid, err := uuid.New().MarshalBinary() uid, err := uuid.New().MarshalBinary()
require.NoError(t, err) require.NoError(t, err)
tok.SetID(uid) tok.SetID(uid)
tokens = append(tokens, tok) tokens = append(tokens, tok)
return tok, err return &ResCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
}).MaxTimes(2) }).MaxTimes(2)
mockClient.EXPECT().GetObject(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil) mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().ObjectGet(gomock.Any(), gomock.Any()).Return(nil, nil)
return mockClient, nil return mockClient, nil
} }
@ -517,7 +550,7 @@ func TestSessionCacheWithKey(t *testing.T) {
cp, err := pool.connection() cp, err := pool.connection()
require.NoError(t, err) require.NoError(t, err)
st := pool.cache.Get(formCacheKey(cp.address, pool.key)) st := pool.cache.Get(formCacheKey(cp.address, pool.key))
require.Contains(t, tokens, st) require.True(t, containsTokens(tokens, st))
var prm PrmObjectGet var prm PrmObjectGet
prm.SetAddress(address.Address{}) prm.SetAddress(address.Address{})
@ -543,9 +576,9 @@ func TestSessionTokenOwner(t *testing.T) {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
clientBuilder := func(_ string) (client, error) { clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(&sdkClient.ResSessionCreate{}, nil).AnyTimes() mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResEndpointInfo{}, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil return mockClient, nil
} }
@ -571,11 +604,13 @@ func TestSessionTokenOwner(t *testing.T) {
var prm prmCommon var prm prmCommon
prm.UseKey(anonKey) prm.UseKey(anonKey)
prm.useDefaultSession() var prmCtx prmContext
prmCtx.useDefaultSession()
var cc callContext var cc callContext
cc.Context = ctx cc.Context = ctx
cc.sessionTarget = func(session.Token) {} cc.sessionTarget = func(session.Token) {}
err = p.initCallContext(&cc, prm) err = p.initCallContext(&cc, prm, prmCtx)
require.NoError(t, err) require.NoError(t, err)
err = p.openDefaultSession(&cc) err = p.openDefaultSession(&cc)
@ -589,10 +624,10 @@ func TestWaitPresence(t *testing.T) {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
mockClient := NewMockClient(ctrl) mockClient := NewMockClient(ctrl)
mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&sdkClient.ResNetworkInfo{}, nil).AnyTimes() mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().GetContainer(gomock.Any(), gomock.Any()).Return(&sdkClient.ResContainerGet{}, nil).AnyTimes() mockClient.EXPECT().ContainerGet(gomock.Any(), gomock.Any()).Return(&container.Container{}, nil).AnyTimes()
cache, err := newCache() cache, err := newCache()
require.NoError(t, err) require.NoError(t, err)

View file

@ -6,7 +6,7 @@ import (
"math/rand" "math/rand"
"testing" "testing"
sdkClient "github.com/nspcc-dev/neofs-sdk-go/client" "github.com/nspcc-dev/neofs-sdk-go/netmap"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -43,16 +43,16 @@ func TestSamplerStability(t *testing.T) {
} }
type clientMock struct { type clientMock struct {
sdkClient.Client clientWrapper
name string name string
err error err error
} }
func (c *clientMock) EndpointInfo(context.Context, sdkClient.PrmEndpointInfo) (*sdkClient.ResEndpointInfo, error) { func (c *clientMock) EndpointInfo(context.Context, PrmEndpointInfo) (*netmap.NodeInfo, error) {
return nil, nil return nil, nil
} }
func (c *clientMock) NetworkInfo(context.Context, sdkClient.PrmNetworkInfo) (*sdkClient.ResNetworkInfo, error) { func (c *clientMock) NetworkInfo(context.Context, PrmNetworkInfo) (*netmap.NetworkInfo, error) {
return nil, nil return nil, nil
} }