From f296491c118a78472450b06ece8df229b87b7761 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Thu, 2 May 2024 10:39:08 +0300 Subject: [PATCH] when in tests, send cobra help and errors to discard Signed-off-by: Avi Deitcher --- cmd/dump_test.go | 2 ++ cmd/prune_test.go | 2 ++ cmd/restore_test.go | 2 ++ 3 files changed, 6 insertions(+) diff --git a/cmd/dump_test.go b/cmd/dump_test.go index d9e16505..fea44779 100644 --- a/cmd/dump_test.go +++ b/cmd/dump_test.go @@ -1,6 +1,7 @@ package cmd import ( + "io" "net/url" "testing" @@ -140,6 +141,7 @@ func TestDumpCmd(t *testing.T) { if err != nil { t.Fatal(err) } + cmd.SetOutput(io.Discard) cmd.SetArgs(append([]string{"dump"}, tt.args...)) err = cmd.Execute() switch { diff --git a/cmd/prune_test.go b/cmd/prune_test.go index ef502969..f160a12f 100644 --- a/cmd/prune_test.go +++ b/cmd/prune_test.go @@ -1,6 +1,7 @@ package cmd import ( + "io" "net/url" "testing" @@ -43,6 +44,7 @@ func TestPruneCmd(t *testing.T) { if err != nil { t.Fatal(err) } + cmd.SetOutput(io.Discard) cmd.SetArgs(append([]string{"prune"}, tt.args...)) err = cmd.Execute() switch { diff --git a/cmd/restore_test.go b/cmd/restore_test.go index cd280aa0..3484f1b2 100644 --- a/cmd/restore_test.go +++ b/cmd/restore_test.go @@ -1,6 +1,7 @@ package cmd import ( + "io" "net/url" "testing" @@ -49,6 +50,7 @@ func TestRestoreCmd(t *testing.T) { if err != nil { t.Fatal(err) } + cmd.SetOutput(io.Discard) cmd.SetArgs(append([]string{"restore"}, tt.args...)) err = cmd.Execute() switch {