From 9347fed154997013a8dafcd6a63c959042a9ea0a Mon Sep 17 00:00:00 2001 From: Jeremy Chou Date: Thu, 7 Jul 2022 00:28:58 +0800 Subject: [PATCH] =?UTF-8?q?[api]=20impletment=20TestGrpcServer=5FGetAccoun?= =?UTF-8?q?t=20by=20gomock=20CoreService=20inte=E2=80=A6=20(#3488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [api] impletment TestGrpcServer_GetAccount by gomock CoreService interface --- api/grpcserver_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/api/grpcserver_test.go b/api/grpcserver_test.go index e91dbeedaa..91b0c280f9 100644 --- a/api/grpcserver_test.go +++ b/api/grpcserver_test.go @@ -23,7 +23,27 @@ import ( ) func TestGrpcServer_GetAccount(t *testing.T) { + require := require.New(t) + ctrl := gomock.NewController(t) + defer ctrl.Finish() + core := mock_apicoreservice.NewMockCoreService(ctrl) + grpcSvr := newGRPCHandler(core) + for _, test := range _getAccountTests { + accountMeta := &iotextypes.AccountMeta{ + Address: test.address, + } + blockIdentifier := &iotextypes.BlockIdentifier{} + request := &iotexapi.GetAccountRequest{ + Address: test.address, + } + + core.EXPECT().Account(gomock.Any()).Return(accountMeta, blockIdentifier, nil) + + res, err := grpcSvr.GetAccount(context.Background(), request) + require.NoError(err) + require.Equal(test.address, res.AccountMeta.Address) + } } func TestGrpcServer_GetActions(t *testing.T) {