diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-08-31 14:56:37 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2021-08-31 14:57:16 +0200 |
commit | d4f21eb03387317d718ccef2002c32852f664843 (patch) | |
tree | 61a664ce10bae548cc2d2753f779f394e51f9c8a /client/go/cmd/command_tester.go | |
parent | 0d6692e624dc031a5769ac6a832930d06dc68bcb (diff) |
Add support for setting default application in config
Diffstat (limited to 'client/go/cmd/command_tester.go')
-rw-r--r-- | client/go/cmd/command_tester.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/client/go/cmd/command_tester.go b/client/go/cmd/command_tester.go index cbd169dfb4b..46c37e0fbd2 100644 --- a/client/go/cmd/command_tester.go +++ b/client/go/cmd/command_tester.go @@ -20,7 +20,7 @@ import ( "github.com/vespa-engine/vespa/util" ) -func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArgs []string) (standardout string) { +func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArgs []string) string { if client != nil { util.ActiveHttpClient = client } @@ -30,13 +30,16 @@ func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArg // Use a separate config dir for each test os.Setenv("VESPA_CLI_HOME", t.TempDir()) - viper.Reset() // Reset config in case tests manipulate it + if len(args) > 0 && args[0] != "config" { + viper.Reset() // Reset config unless we're testing the config sub-command + } // Reset to default target - persistent flags in Cobra persists over tests log.SetOutput(bytes.NewBufferString("")) rootCmd.SetArgs([]string{"status", "-t", "local"}) rootCmd.Execute() + // Capture stdout and execute command b := bytes.NewBufferString("") log.SetOutput(b) rootCmd.SetArgs(append(args, moreArgs...)) |