add assert to output for wallet list

This commit is contained in:
TheMenko 2022-03-01 02:21:22 +01:00
parent cd64eba76c
commit 0708268c75
2 changed files with 6 additions and 4 deletions

View File

@ -102,6 +102,8 @@ var walletList = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
afmt := NewAppFmt(cctx.App)
addrs, err := api.WalletList(ctx)
if err != nil {
return err
@ -122,7 +124,7 @@ var walletList = &cli.Command{
for _, addr := range addrs {
if cctx.Bool("addr-only") {
fmt.Println(addr.String())
afmt.Println(addr.String())
} else {
a, err := api.StateGetActor(ctx, addr, types.EmptyTSK)
if err != nil {

View File

@ -58,7 +58,7 @@ func TestWalletList(t *testing.T) {
t.Run("wallet-list-addr-only", func(t *testing.T) {
app, mockApi, _, done := NewMockAppWithFullAPI(t, WithCategory("wallet", walletList))
app, mockApi, buf, done := NewMockAppWithFullAPI(t, WithCategory("wallet", walletList))
defer done()
ctx, cancel := context.WithCancel(context.Background())
@ -67,12 +67,12 @@ func TestWalletList(t *testing.T) {
gomock.InOrder(
mockApi.EXPECT().WalletList(ctx).Return(addresses, nil),
mockApi.EXPECT().WalletDefaultAddress(ctx).Return(addr, nil),
mockApi.EXPECT().StateGetActor(ctx, addr, key).Return(&actor, nil),
)
//stm: @CLI_WALLET_LIST_001
err := app.Run([]string{"wallet", "list", "addr-only"})
err := app.Run([]string{"wallet", "list", "--addr-only"})
assert.NoError(t, err)
assert.Contains(t, buf.String(), addr.String())
})
t.Run("wallet-list-id", func(t *testing.T) {