github.com/braveheart12/just@v0.8.7/pulsar/pulsartestutils/mockrpcclientwrapper.go (about) 1 /* 2 * Copyright 2019 Insolar Technologies 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // Package pulsartestutil - test utils for pulsar package 18 package pulsartestutils 19 20 import ( 21 "net/rpc" 22 23 "github.com/insolar/insolar/configuration" 24 "github.com/stretchr/testify/mock" 25 ) 26 27 // MockRPCClientWrapper is a mock of RPCClientWrapper interface 28 // It uses testify.mock 29 type MockRPCClientWrapper struct { 30 mock.Mock 31 } 32 33 func (mock *MockRPCClientWrapper) Lock() { 34 mock.Mock.Called() 35 } 36 37 func (mock *MockRPCClientWrapper) Unlock() { 38 mock.Mock.Called() 39 } 40 41 func (mock *MockRPCClientWrapper) IsInitialised() bool { 42 args := mock.Mock.Called() 43 return args.Bool(0) 44 } 45 46 func (mock *MockRPCClientWrapper) SetRPCClient(client *rpc.Client) { 47 mock.Mock.Called(client) 48 } 49 50 func (mock *MockRPCClientWrapper) CreateConnection(connectionType configuration.ConnectionType, connectionAddress string) error { 51 args := mock.Mock.Called(connectionType, connectionAddress) 52 return args.Error(0) 53 } 54 55 func (mock *MockRPCClientWrapper) Close() error { 56 args := mock.Mock.Called() 57 return args.Error(0) 58 } 59 60 func (mock *MockRPCClientWrapper) ResetClient() { 61 mock.Called() 62 } 63 64 func (mock *MockRPCClientWrapper) Go(serviceMethod string, args interface{}, reply interface{}, done chan *rpc.Call) *rpc.Call { 65 mockArgs := mock.Mock.Called(serviceMethod, args, reply, done) 66 return mockArgs.Get(0).(*rpc.Call) 67 }