diff options
Diffstat (limited to 'client/go/cmd/api_key_test.go')
-rw-r--r-- | client/go/cmd/api_key_test.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/client/go/cmd/api_key_test.go b/client/go/cmd/api_key_test.go index ba697b69d9f..3e3a7fa0a31 100644 --- a/client/go/cmd/api_key_test.go +++ b/client/go/cmd/api_key_test.go @@ -4,7 +4,6 @@ package cmd import ( - "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -20,16 +19,20 @@ func TestAPIKey(t *testing.T) { } func testAPIKey(t *testing.T, subcommand []string) { - homeDir := filepath.Join(t.TempDir(), ".vespa") - keyFile := filepath.Join(homeDir, "t1.api-key.pem") + cli, stdout, stderr := newTestCLI(t) - execute(command{args: []string{"config", "set", "target", "cloud"}, homeDir: homeDir}, t, nil) + err := cli.Run("config", "set", "target", "cloud") + assert.Nil(t, err) args := append(subcommand, "-a", "t1.a1.i1") - out, _ := execute(command{args: args, homeDir: homeDir}, t, nil) - assert.Contains(t, out, "Success: API private key written to "+keyFile+"\n") - - out, outErr := execute(command{args: args, homeDir: homeDir}, t, nil) - assert.Contains(t, outErr, "Error: refusing to overwrite "+keyFile+"\nHint: Use -f to overwrite it\n") - assert.Contains(t, out, "This is your public key") + err = cli.Run(args...) + assert.Nil(t, err) + assert.Equal(t, "", stderr.String()) + assert.Contains(t, stdout.String(), "Success: API private key written to") + + err = cli.Run(subcommand...) + assert.NotNil(t, err) + assert.Contains(t, stderr.String(), "Error: refusing to overwrite") + assert.Contains(t, stderr.String(), "Hint: Use -f to overwrite it\n") + assert.Contains(t, stdout.String(), "This is your public key") } |