github.com/iotexproject/iotex-core@v1.14.1-rc1/ioctl/newcmd/hdwallet/hdwalletdelete_test.go (about) 1 // Copyright (c) 2022 IoTeX Foundation 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package hdwallet 7 8 import ( 9 "testing" 10 11 "github.com/golang/mock/gomock" 12 "github.com/stretchr/testify/require" 13 14 "github.com/iotexproject/iotex-core/ioctl/config" 15 "github.com/iotexproject/iotex-core/ioctl/util" 16 "github.com/iotexproject/iotex-core/test/mock/mock_ioctlclient" 17 ) 18 19 func TestNewHdwalletDeleteCmd(t *testing.T) { 20 require := require.New(t) 21 ctrl := gomock.NewController(t) 22 client := mock_ioctlclient.NewMockClient(ctrl) 23 24 client.EXPECT().SelectTranslation(gomock.Any()).Return("mockTranslationString", config.English).AnyTimes() 25 26 t.Run("delete hdwallet", func(t *testing.T) { 27 client.EXPECT().AskToConfirm(gomock.Any()).Return(true, nil) 28 client.EXPECT().RemoveHdWalletConfigFile().Return(nil) 29 30 cmd := NewHdwalletDeleteCmd(client) 31 result, err := util.ExecuteCmd(cmd) 32 require.NoError(err) 33 require.Equal("", result) 34 }) 35 36 t.Run("quit hdwallet delete command", func(t *testing.T) { 37 client.EXPECT().AskToConfirm(gomock.Any()).Return(false, nil) 38 39 cmd := NewHdwalletDeleteCmd(client) 40 result, err := util.ExecuteCmd(cmd) 41 require.NoError(err) 42 require.Equal("quit\n", result) 43 }) 44 }