From 171fd18a9a8a4c3eefd2e6b86e3380e825f1009a Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Mon, 30 Mar 2020 02:49:52 +0200 Subject: [PATCH] Fix test --- client/keys/add_test.go | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/client/keys/add_test.go b/client/keys/add_test.go index 4a079719e96b..172d7d9e1ce6 100644 --- a/client/keys/add_test.go +++ b/client/keys/add_test.go @@ -16,7 +16,6 @@ import ( ) func Test_runAddCmdBasic(t *testing.T) { - runningUnattended := isRunningUnattended() cmd := AddKeyCommand() assert.NotNil(t, cmd) mockIn, _, _ := tests.ApplyMockIO(cmd) @@ -27,33 +26,21 @@ func Test_runAddCmdBasic(t *testing.T) { viper.Set(flags.FlagHome, kbHome) viper.Set(cli.OutputFlag, OutputFormatText) - if runningUnattended { - mockIn.Reset("testpass1\ntestpass1\n") - } else { - mockIn.Reset("y\n") - kb, err := keyring.NewKeyring(sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), kbHome, mockIn) - require.NoError(t, err) - t.Cleanup(func() { - kb.Delete("keyname1", "", false) // nolint:errcheck - kb.Delete("keyname2", "", false) // nolint:errcheck - }) - } + mockIn.Reset("y\n") + kb, err := keyring.NewKeyring(sdk.KeyringServiceName(), viper.GetString(flags.FlagKeyringBackend), kbHome, mockIn) + require.NoError(t, err) + t.Cleanup(func() { + kb.Delete("keyname1", "", false) // nolint:errcheck + kb.Delete("keyname2", "", false) // nolint:errcheck + }) assert.NoError(t, runAddCmd(cmd, []string{"keyname1"})) - if runningUnattended { - mockIn.Reset("testpass1\nN\n") - } else { - mockIn.Reset("N\n") - } + mockIn.Reset("N\n") assert.Error(t, runAddCmd(cmd, []string{"keyname1"})) assert.NoError(t, runAddCmd(cmd, []string{"keyname2"})) assert.Error(t, runAddCmd(cmd, []string{"keyname2"})) - if runningUnattended { - mockIn.Reset("testpass1\nN\n") - } else { - mockIn.Reset("y\n") - } + mockIn.Reset("y\n") assert.NoError(t, runAddCmd(cmd, []string{"keyname2"})) // test --dry-run