fix: Avoid dirtying stdout/stderr in test (#3165)

* fix: Default all clitest commands to io.Discard stdout/err

* fix: Never write to stdout or stderr in tests
This commit is contained in:
Mathias Fredriksson
2022-07-25 16:55:53 +03:00
committed by GitHub
parent ad2b29a571
commit 233aa17848
4 changed files with 13 additions and 7 deletions
+6
View File
@@ -25,6 +25,12 @@ func New(t *testing.T, args ...string) (*cobra.Command, config.Root) {
dir := t.TempDir()
root := config.Root(dir)
cmd.SetArgs(append([]string{"--global-config", dir}, args...))
// We could consider using writers
// that log via t.Log here instead.
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
return cmd, root
}