mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user