github.com/ConsenSys/Quorum@v20.10.0+incompatible/plugin/helloworld/gateway_test.go (about) 1 package helloworld 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/golang/mock/gomock" 8 "github.com/jpmorganchase/quorum-hello-world-plugin-sdk-go/mock_proto" 9 "github.com/jpmorganchase/quorum-hello-world-plugin-sdk-go/proto" 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestPluginPingPong_Ping(t *testing.T) { 14 ctrl := gomock.NewController(t) 15 defer ctrl.Finish() 16 req := &proto.PluginHelloWorld_Request{ 17 Msg: "arbitrary msg", 18 } 19 mockClient := mock_proto.NewMockPluginGreetingClient(ctrl) 20 mockClient. 21 EXPECT(). 22 Greeting(gomock.Any(), gomock.Eq(req)). 23 Return(&proto.PluginHelloWorld_Response{ 24 Msg: "arbitrary response", 25 }, nil) 26 testObject := &PluginGateway{client: mockClient} 27 28 resp, err := testObject.Greeting(context.Background(), "arbitrary msg") 29 30 assert.NoError(t, err) 31 assert.Equal(t, "arbitrary response", resp) 32 }