Skip to content

Commit

Permalink
[api] impletment TestGrpcServer_GetAccount by gomock CoreService inte… (
Browse files Browse the repository at this point in the history
#3488)

* [api] impletment TestGrpcServer_GetAccount by gomock CoreService interface
  • Loading branch information
LuckyPigeon authored Jul 6, 2022
1 parent a48569e commit 9347fed
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api/grpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9347fed

Please sign in to comment.