Fix services mock generation (#901)

This commit is contained in:
Adrià Cidre 2018-05-07 10:22:38 +02:00 committed by GitHub
parent 1afb26c3f4
commit 246c5321ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 53 deletions

View File

@ -12,31 +12,31 @@ import (
reflect "reflect" reflect "reflect"
) )
// MockWhisper is a mock of Whisper interface // MockWhisperService is a mock of WhisperService interface
type MockWhisper struct { type MockWhisperService struct {
ctrl *gomock.Controller ctrl *gomock.Controller
recorder *MockWhisperMockRecorder recorder *MockWhisperServiceMockRecorder
} }
// MockWhisperMockRecorder is the mock recorder for MockWhisper // MockWhisperServiceMockRecorder is the mock recorder for MockWhisperService
type MockWhisperMockRecorder struct { type MockWhisperServiceMockRecorder struct {
mock *MockWhisper mock *MockWhisperService
} }
// NewMockWhisper creates a new mock instance // NewMockWhisperService creates a new mock instance
func NewMockWhisper(ctrl *gomock.Controller) *MockWhisper { func NewMockWhisperService(ctrl *gomock.Controller) *MockWhisperService {
mock := &MockWhisper{ctrl: ctrl} mock := &MockWhisperService{ctrl: ctrl}
mock.recorder = &MockWhisperMockRecorder{mock} mock.recorder = &MockWhisperServiceMockRecorder{mock}
return mock return mock
} }
// EXPECT returns an object that allows the caller to indicate expected use // EXPECT returns an object that allows the caller to indicate expected use
func (m *MockWhisper) EXPECT() *MockWhisperMockRecorder { func (m *MockWhisperService) EXPECT() *MockWhisperServiceMockRecorder {
return m.recorder return m.recorder
} }
// AddKeyPair mocks base method // AddKeyPair mocks base method
func (m *MockWhisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error) { func (m *MockWhisperService) AddKeyPair(key *ecdsa.PrivateKey) (string, error) {
ret := m.ctrl.Call(m, "AddKeyPair", key) ret := m.ctrl.Call(m, "AddKeyPair", key)
ret0, _ := ret[0].(string) ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
@ -44,8 +44,8 @@ func (m *MockWhisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error) {
} }
// AddKeyPair indicates an expected call of AddKeyPair // AddKeyPair indicates an expected call of AddKeyPair
func (mr *MockWhisperMockRecorder) AddKeyPair(key interface{}) *gomock.Call { func (mr *MockWhisperServiceMockRecorder) AddKeyPair(key interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddKeyPair", reflect.TypeOf((*MockWhisper)(nil).AddKeyPair), key) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddKeyPair", reflect.TypeOf((*MockWhisperService)(nil).AddKeyPair), key)
} }
// MockAccountManager is a mock of AccountManager interface // MockAccountManager is a mock of AccountManager interface
@ -111,40 +111,3 @@ func (m *MockAccountManager) CreateAccount(password string) (string, string, str
func (mr *MockAccountManagerMockRecorder) CreateAccount(password interface{}) *gomock.Call { func (mr *MockAccountManagerMockRecorder) CreateAccount(password interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccount", reflect.TypeOf((*MockAccountManager)(nil).CreateAccount), password) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateAccount", reflect.TypeOf((*MockAccountManager)(nil).CreateAccount), password)
} }
// MockWhisperService is a mock of WhisperService interface
type MockWhisperService struct {
ctrl *gomock.Controller
recorder *MockWhisperServiceMockRecorder
}
// MockWhisperServiceMockRecorder is the mock recorder for MockWhisperService
type MockWhisperServiceMockRecorder struct {
mock *MockWhisperService
}
// NewMockWhisperService creates a new mock instance
func NewMockWhisperService(ctrl *gomock.Controller) *MockWhisperService {
mock := &MockWhisperService{ctrl: ctrl}
mock.recorder = &MockWhisperServiceMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockWhisperService) EXPECT() *MockWhisperServiceMockRecorder {
return m.recorder
}
// AddressToDecryptedAccount mocks base method
func (m *MockWhisperService) AddressToDecryptedAccount(arg0, arg1 string) (accounts.Account, *keystore.Key, error) {
ret := m.ctrl.Call(m, "AddressToDecryptedAccount", arg0, arg1)
ret0, _ := ret[0].(accounts.Account)
ret1, _ := ret[1].(*keystore.Key)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// AddressToDecryptedAccount indicates an expected call of AddressToDecryptedAccount
func (mr *MockWhisperServiceMockRecorder) AddressToDecryptedAccount(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddressToDecryptedAccount", reflect.TypeOf((*MockWhisperService)(nil).AddressToDecryptedAccount), arg0, arg1)
}

View File

@ -19,14 +19,14 @@ func TestStatusSuite(t *testing.T) {
type StatusSuite struct { type StatusSuite struct {
suite.Suite suite.Suite
am *MockAccountManager am *MockAccountManager
w *MockWhisper w *MockWhisperService
api *PublicAPI api *PublicAPI
} }
func (s *StatusSuite) SetupTest() { func (s *StatusSuite) SetupTest() {
ctrl := gomock.NewController(s.T()) ctrl := gomock.NewController(s.T())
s.am = NewMockAccountManager(ctrl) s.am = NewMockAccountManager(ctrl)
s.w = NewMockWhisper(ctrl) s.w = NewMockWhisperService(ctrl)
service := New(s.w) service := New(s.w)
service.SetAccountManager(s.am) service.SetAccountManager(s.am)