Switch mockgen to reflect mode (#800)

Switch mockgen to use reflect mode as source mode does not support vendored packages.
This commit is contained in:
Adam Babik 2018-04-05 15:14:47 +02:00 committed by GitHub
parent bd14456e4b
commit e9c2292776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 64 deletions

View File

@ -114,9 +114,9 @@ mock-install: ##@other Install mocking tools
go get -u github.com/golang/mock/mockgen
mock: ##@other Regenerate mocks
mockgen -source=geth/mailservice/mailservice.go -destination=geth/mailservice/mailservice_mock.go -package=mailservice
mockgen -source=geth/notifications/push/fcm/client.go -destination=geth/notifications/push/fcm/client_mock.go -package=fcm -imports fcm=github.com/NaySoftware/go-fcm
mockgen -source=geth/transactions/fake/txservice.go -destination=geth/transactions/fake/mock.go -package=fake
mockgen -package=mailservice -destination=geth/mailservice/mailservice_mock.go github.com/status-im/status-go/geth/mailservice ServiceProvider
mockgen -package=fcm -destination=geth/notifications/push/fcm/client_mock.go github.com/status-im/status-go/geth/notifications/push/fcm FirebaseClient,Notifier
mockgen -package=fake -destination=geth/transactions/fake/mock.go github.com/status-im/status-go/geth/transactions/fake PublicTransactionPoolAPI
docker-test: ##@tests Run tests in a docker container with golang.
docker run --privileged --rm -it -v "$(shell pwd):$(DOCKER_TEST_WORKDIR)" -w "$(DOCKER_TEST_WORKDIR)" $(DOCKER_TEST_IMAGE) go test ${ARGS}

View File

@ -17,10 +17,19 @@ def getVersion(branch, sha, buildNumber) {
node('linux') {
env.GOPATH = "${env.WORKSPACE}"
env.PATH = "${env.PATH}:${env.GOPATH}/bin"
cloneDir = 'src/github.com/status-im/status-go'
paramBranch = env.branch ? ('*/' + env.branch) : '*/develop'
dir(cloneDir) {
try {
deleteDir()
} catch (err) {
echo "failure while cleaning the directory"
}
}
checkout(
changelog: false,
poll: true,
@ -48,12 +57,10 @@ node('linux') {
}
stage('Test') {
sh '''
make lint-install
make mock-install
make ci
'''
dir(cloneDir) {
sh 'make setup'
sh 'make ci'
}
}
stage('Build') {

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: geth/mailservice/mailservice.go
// Source: github.com/status-im/status-go/geth/mailservice (interfaces: ServiceProvider)
// Package mailservice is a generated GoMock package.
package mailservice

View File

@ -2,8 +2,8 @@ package fcm
import "github.com/NaySoftware/go-fcm"
// firebaseClient is a copy of "go-fcm" client methods.
type firebaseClient interface {
// FirebaseClient is a copy of "go-fcm" client methods.
type FirebaseClient interface {
NewFcmRegIdsMsg(tokens []string, body interface{}) *fcm.FcmClient
Send() (*fcm.FcmResponseStatus, error)
SetNotificationPayload(payload *fcm.NotificationPayload) *fcm.FcmClient

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: geth/notifications/push/fcm/client.go
// Source: github.com/status-im/status-go/geth/notifications/push/fcm (interfaces: FirebaseClient,Notifier)
// Package fcm is a generated GoMock package.
package fcm
@ -10,43 +10,43 @@ import (
reflect "reflect"
)
// MockfirebaseClient is a mock of firebaseClient interface
type MockfirebaseClient struct {
// MockFirebaseClient is a mock of FirebaseClient interface
type MockFirebaseClient struct {
ctrl *gomock.Controller
recorder *MockfirebaseClientMockRecorder
recorder *MockFirebaseClientMockRecorder
}
// MockfirebaseClientMockRecorder is the mock recorder for MockfirebaseClient
type MockfirebaseClientMockRecorder struct {
mock *MockfirebaseClient
// MockFirebaseClientMockRecorder is the mock recorder for MockFirebaseClient
type MockFirebaseClientMockRecorder struct {
mock *MockFirebaseClient
}
// NewMockfirebaseClient creates a new mock instance
func NewMockfirebaseClient(ctrl *gomock.Controller) *MockfirebaseClient {
mock := &MockfirebaseClient{ctrl: ctrl}
mock.recorder = &MockfirebaseClientMockRecorder{mock}
// NewMockFirebaseClient creates a new mock instance
func NewMockFirebaseClient(ctrl *gomock.Controller) *MockFirebaseClient {
mock := &MockFirebaseClient{ctrl: ctrl}
mock.recorder = &MockFirebaseClientMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockfirebaseClient) EXPECT() *MockfirebaseClientMockRecorder {
func (m *MockFirebaseClient) EXPECT() *MockFirebaseClientMockRecorder {
return m.recorder
}
// NewFcmRegIdsMsg mocks base method
func (m *MockfirebaseClient) NewFcmRegIdsMsg(tokens []string, body interface{}) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "NewFcmRegIdsMsg", tokens, body)
func (m *MockFirebaseClient) NewFcmRegIdsMsg(arg0 []string, arg1 interface{}) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "NewFcmRegIdsMsg", arg0, arg1)
ret0, _ := ret[0].(*go_fcm.FcmClient)
return ret0
}
// NewFcmRegIdsMsg indicates an expected call of NewFcmRegIdsMsg
func (mr *MockfirebaseClientMockRecorder) NewFcmRegIdsMsg(tokens, body interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewFcmRegIdsMsg", reflect.TypeOf((*MockfirebaseClient)(nil).NewFcmRegIdsMsg), tokens, body)
func (mr *MockFirebaseClientMockRecorder) NewFcmRegIdsMsg(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewFcmRegIdsMsg", reflect.TypeOf((*MockFirebaseClient)(nil).NewFcmRegIdsMsg), arg0, arg1)
}
// Send mocks base method
func (m *MockfirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) {
func (m *MockFirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) {
ret := m.ctrl.Call(m, "Send")
ret0, _ := ret[0].(*go_fcm.FcmResponseStatus)
ret1, _ := ret[1].(error)
@ -54,18 +54,58 @@ func (m *MockfirebaseClient) Send() (*go_fcm.FcmResponseStatus, error) {
}
// Send indicates an expected call of Send
func (mr *MockfirebaseClientMockRecorder) Send() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockfirebaseClient)(nil).Send))
func (mr *MockFirebaseClientMockRecorder) Send() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockFirebaseClient)(nil).Send))
}
// SetNotificationPayload mocks base method
func (m *MockfirebaseClient) SetNotificationPayload(payload *go_fcm.NotificationPayload) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "SetNotificationPayload", payload)
func (m *MockFirebaseClient) SetNotificationPayload(arg0 *go_fcm.NotificationPayload) *go_fcm.FcmClient {
ret := m.ctrl.Call(m, "SetNotificationPayload", arg0)
ret0, _ := ret[0].(*go_fcm.FcmClient)
return ret0
}
// SetNotificationPayload indicates an expected call of SetNotificationPayload
func (mr *MockfirebaseClientMockRecorder) SetNotificationPayload(payload interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNotificationPayload", reflect.TypeOf((*MockfirebaseClient)(nil).SetNotificationPayload), payload)
func (mr *MockFirebaseClientMockRecorder) SetNotificationPayload(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNotificationPayload", reflect.TypeOf((*MockFirebaseClient)(nil).SetNotificationPayload), arg0)
}
// MockNotifier is a mock of Notifier interface
type MockNotifier struct {
ctrl *gomock.Controller
recorder *MockNotifierMockRecorder
}
// MockNotifierMockRecorder is the mock recorder for MockNotifier
type MockNotifierMockRecorder struct {
mock *MockNotifier
}
// NewMockNotifier creates a new mock instance
func NewMockNotifier(ctrl *gomock.Controller) *MockNotifier {
mock := &MockNotifier{ctrl: ctrl}
mock.recorder = &MockNotifierMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockNotifier) EXPECT() *MockNotifierMockRecorder {
return m.recorder
}
// Send mocks base method
func (m *MockNotifier) Send(arg0 string, arg1 go_fcm.NotificationPayload, arg2 ...string) error {
varargs := []interface{}{arg0, arg1}
for _, a := range arg2 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Send", varargs...)
ret0, _ := ret[0].(error)
return ret0
}
// Send indicates an expected call of Send
func (mr *MockNotifierMockRecorder) Send(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {
varargs := append([]interface{}{arg0, arg1}, arg2...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockNotifier)(nil).Send), varargs...)
}

View File

@ -16,7 +16,7 @@ type NotificationConstructor func() Notifier
// Notification represents messaging provider for notifications.
type Notification struct {
client firebaseClient
client FirebaseClient
}
// NewNotification Firebase Cloud Messaging client constructor.

View File

@ -16,13 +16,13 @@ func TestFCMClientTestSuite(t *testing.T) {
type NotifierTestSuite struct {
suite.Suite
fcmClientMock *MockfirebaseClient
fcmClientMock *MockFirebaseClient
fcmClientMockCtrl *gomock.Controller
}
func (s *NotifierTestSuite) SetupTest() {
s.fcmClientMockCtrl = gomock.NewController(s.T())
s.fcmClientMock = NewMockfirebaseClient(s.fcmClientMockCtrl)
s.fcmClientMock = NewMockFirebaseClient(s.fcmClientMockCtrl)
}
func (s *NotifierTestSuite) TearDownTest() {

View File

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: geth/transactions/fake/txservice.go
// Source: github.com/status-im/status-go/geth/transactions/fake (interfaces: PublicTransactionPoolAPI)
// Package fake is a generated GoMock package.
package fake
@ -37,54 +37,54 @@ func (m *MockPublicTransactionPoolAPI) EXPECT() *MockPublicTransactionPoolAPIMoc
return m.recorder
}
// GasPrice mocks base method
func (m *MockPublicTransactionPoolAPI) GasPrice(ctx context.Context) (*big.Int, error) {
ret := m.ctrl.Call(m, "GasPrice", ctx)
ret0, _ := ret[0].(*big.Int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GasPrice indicates an expected call of GasPrice
func (mr *MockPublicTransactionPoolAPIMockRecorder) GasPrice(ctx interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasPrice", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).GasPrice), ctx)
}
// EstimateGas mocks base method
func (m *MockPublicTransactionPoolAPI) EstimateGas(ctx context.Context, args CallArgs) (hexutil.Uint64, error) {
ret := m.ctrl.Call(m, "EstimateGas", ctx, args)
func (m *MockPublicTransactionPoolAPI) EstimateGas(arg0 context.Context, arg1 CallArgs) (hexutil.Uint64, error) {
ret := m.ctrl.Call(m, "EstimateGas", arg0, arg1)
ret0, _ := ret[0].(hexutil.Uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// EstimateGas indicates an expected call of EstimateGas
func (mr *MockPublicTransactionPoolAPIMockRecorder) EstimateGas(ctx, args interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EstimateGas", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).EstimateGas), ctx, args)
func (mr *MockPublicTransactionPoolAPIMockRecorder) EstimateGas(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EstimateGas", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).EstimateGas), arg0, arg1)
}
// GasPrice mocks base method
func (m *MockPublicTransactionPoolAPI) GasPrice(arg0 context.Context) (*big.Int, error) {
ret := m.ctrl.Call(m, "GasPrice", arg0)
ret0, _ := ret[0].(*big.Int)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GasPrice indicates an expected call of GasPrice
func (mr *MockPublicTransactionPoolAPIMockRecorder) GasPrice(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GasPrice", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).GasPrice), arg0)
}
// GetTransactionCount mocks base method
func (m *MockPublicTransactionPoolAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Uint64, error) {
ret := m.ctrl.Call(m, "GetTransactionCount", ctx, address, blockNr)
func (m *MockPublicTransactionPoolAPI) GetTransactionCount(arg0 context.Context, arg1 common.Address, arg2 rpc.BlockNumber) (*hexutil.Uint64, error) {
ret := m.ctrl.Call(m, "GetTransactionCount", arg0, arg1, arg2)
ret0, _ := ret[0].(*hexutil.Uint64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetTransactionCount indicates an expected call of GetTransactionCount
func (mr *MockPublicTransactionPoolAPIMockRecorder) GetTransactionCount(ctx, address, blockNr interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionCount", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).GetTransactionCount), ctx, address, blockNr)
func (mr *MockPublicTransactionPoolAPIMockRecorder) GetTransactionCount(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransactionCount", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).GetTransactionCount), arg0, arg1, arg2)
}
// SendRawTransaction mocks base method
func (m *MockPublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {
ret := m.ctrl.Call(m, "SendRawTransaction", ctx, encodedTx)
func (m *MockPublicTransactionPoolAPI) SendRawTransaction(arg0 context.Context, arg1 hexutil.Bytes) (common.Hash, error) {
ret := m.ctrl.Call(m, "SendRawTransaction", arg0, arg1)
ret0, _ := ret[0].(common.Hash)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SendRawTransaction indicates an expected call of SendRawTransaction
func (mr *MockPublicTransactionPoolAPIMockRecorder) SendRawTransaction(ctx, encodedTx interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRawTransaction", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).SendRawTransaction), ctx, encodedTx)
func (mr *MockPublicTransactionPoolAPIMockRecorder) SendRawTransaction(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendRawTransaction", reflect.TypeOf((*MockPublicTransactionPoolAPI)(nil).SendRawTransaction), arg0, arg1)
}