From f62883520e343a2f99f0326b04b7bf9a41dc0d98 Mon Sep 17 00:00:00 2001 From: Kanji Yomoda Date: Thu, 2 Apr 2020 01:25:22 +0900 Subject: [PATCH] Replace deprecated SetOutput func with SetOut and SetErr in test (#1053) --- cobra/cmd/golden_test.go | 6 ++++-- command_test.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cobra/cmd/golden_test.go b/cobra/cmd/golden_test.go index 9010caa..e4055f3 100644 --- a/cobra/cmd/golden_test.go +++ b/cobra/cmd/golden_test.go @@ -13,8 +13,10 @@ var update = flag.Bool("update", false, "update .golden files") func init() { // Mute commands. - addCmd.SetOutput(new(bytes.Buffer)) - initCmd.SetOutput(new(bytes.Buffer)) + addCmd.SetOut(new(bytes.Buffer)) + addCmd.SetErr(new(bytes.Buffer)) + initCmd.SetOut(new(bytes.Buffer)) + initCmd.SetErr(new(bytes.Buffer)) } // ensureLF converts any \r\n to \n diff --git a/command_test.go b/command_test.go index abee7ba..8ec52f4 100644 --- a/command_test.go +++ b/command_test.go @@ -21,7 +21,8 @@ func executeCommand(root *Command, args ...string) (output string, err error) { func executeCommandWithContext(ctx context.Context, root *Command, args ...string) (output string, err error) { buf := new(bytes.Buffer) - root.SetOutput(buf) + root.SetOut(buf) + root.SetErr(buf) root.SetArgs(args) err = root.ExecuteContext(ctx) @@ -31,7 +32,8 @@ func executeCommandWithContext(ctx context.Context, root *Command, args ...strin func executeCommandC(root *Command, args ...string) (c *Command, output string, err error) { buf := new(bytes.Buffer) - root.SetOutput(buf) + root.SetOut(buf) + root.SetErr(buf) root.SetArgs(args) c, err = root.ExecuteC()