mirror of
https://github.com/spf13/cobra
synced 2024-11-04 21:07:19 +00:00
Replace deprecated SetOutput func with SetOut and SetErr in test (#1053)
This commit is contained in:
parent
6607e6b860
commit
f62883520e
2 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue