From 719169db632cb726644b92d78a1f9f614eead76f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 7 May 2020 14:25:59 +0200 Subject: [PATCH] Replace deprecated Cobra command.SetOutput() with command.SetOut() Signed-off-by: Sebastiaan van Stijn --- cli-plugins/plugin/plugin.go | 2 +- cli/command/checkpoint/create_test.go | 2 +- cli/command/checkpoint/list_test.go | 2 +- cli/command/checkpoint/remove_test.go | 2 +- cli/command/cli.go | 2 +- cli/command/config/create_test.go | 2 +- cli/command/config/inspect_test.go | 2 +- cli/command/config/ls_test.go | 2 +- cli/command/config/remove_test.go | 4 ++-- cli/command/container/attach_test.go | 2 +- cli/command/container/create_test.go | 6 +++--- cli/command/container/exec_test.go | 2 +- cli/command/container/export_test.go | 4 ++-- cli/command/container/list_test.go | 2 +- cli/command/container/run_test.go | 2 +- cli/command/image/build_test.go | 4 ++-- cli/command/image/history_test.go | 4 ++-- cli/command/image/import_test.go | 6 +++--- cli/command/image/inspect_test.go | 4 ++-- cli/command/image/list_test.go | 4 ++-- cli/command/image/load_test.go | 6 +++--- cli/command/image/prune_test.go | 4 ++-- cli/command/image/pull_test.go | 6 +++--- cli/command/image/push_test.go | 4 ++-- cli/command/image/remove_test.go | 4 ++-- cli/command/image/save_test.go | 4 ++-- cli/command/image/tag_test.go | 4 ++-- cli/command/manifest/annotate_test.go | 4 ++-- cli/command/manifest/create_test.go | 8 ++++---- cli/command/manifest/inspect_test.go | 6 +++--- cli/command/manifest/push_test.go | 2 +- cli/command/network/connect_test.go | 2 +- cli/command/network/create_test.go | 2 +- cli/command/network/disconnect_test.go | 2 +- cli/command/network/list_test.go | 2 +- cli/command/node/demote_test.go | 2 +- cli/command/node/inspect_test.go | 2 +- cli/command/node/list_test.go | 2 +- cli/command/node/promote_test.go | 2 +- cli/command/node/ps_test.go | 2 +- cli/command/node/remove_test.go | 2 +- cli/command/node/update_test.go | 2 +- cli/command/plugin/create_test.go | 10 +++++----- cli/command/plugin/disable_test.go | 2 +- cli/command/plugin/enable_test.go | 2 +- cli/command/plugin/inspect_test.go | 2 +- cli/command/plugin/install_test.go | 4 ++-- cli/command/plugin/list_test.go | 2 +- cli/command/plugin/remove_test.go | 2 +- cli/command/secret/create_test.go | 2 +- cli/command/secret/inspect_test.go | 2 +- cli/command/secret/ls_test.go | 2 +- cli/command/secret/remove_test.go | 4 ++-- cli/command/service/rollback_test.go | 4 ++-- cli/command/stack/deploy_test.go | 2 +- cli/command/stack/list_test.go | 2 +- cli/command/stack/ps_test.go | 4 ++-- cli/command/stack/remove_test.go | 4 ++-- cli/command/stack/services_test.go | 4 ++-- cli/command/swarm/ca_test.go | 10 +++++----- cli/command/swarm/init_test.go | 2 +- cli/command/swarm/join_test.go | 2 +- cli/command/swarm/join_token_test.go | 2 +- cli/command/swarm/leave_test.go | 2 +- cli/command/swarm/unlock_key_test.go | 2 +- cli/command/swarm/unlock_test.go | 2 +- cli/command/swarm/update_test.go | 4 ++-- cli/command/system/version_test.go | 2 +- cli/command/trust/inspect_pretty_test.go | 14 +++++++------- cli/command/trust/inspect_test.go | 4 ++-- cli/command/trust/key_generate_test.go | 2 +- cli/command/trust/key_load_test.go | 2 +- cli/command/trust/revoke_test.go | 4 ++-- cli/command/trust/sign_test.go | 8 ++++---- cli/command/trust/signer_add_test.go | 8 ++++---- cli/command/trust/signer_remove_test.go | 4 ++-- cli/command/volume/create_test.go | 2 +- cli/command/volume/inspect_test.go | 2 +- cli/command/volume/list_test.go | 2 +- cli/command/volume/prune_test.go | 2 +- cli/command/volume/remove_test.go | 2 +- cli/required_test.go | 2 +- cmd/docker/docker.go | 2 +- 83 files changed, 138 insertions(+), 138 deletions(-) diff --git a/cli-plugins/plugin/plugin.go b/cli-plugins/plugin/plugin.go index 74f3262b23..0c3b1bf077 100644 --- a/cli-plugins/plugin/plugin.go +++ b/cli-plugins/plugin/plugin.go @@ -128,7 +128,7 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta } opts, flags := cli.SetupPluginRootCommand(cmd) - cmd.SetOutput(dockerCli.Out()) + cmd.SetOut(dockerCli.Out()) cmd.AddCommand( plugin, diff --git a/cli/command/checkpoint/create_test.go b/cli/command/checkpoint/create_test.go index 4c10e5f2aa..cdd15467d8 100644 --- a/cli/command/checkpoint/create_test.go +++ b/cli/command/checkpoint/create_test.go @@ -41,7 +41,7 @@ func TestCheckpointCreateErrors(t *testing.T) { }) cmd := newCreateCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/checkpoint/list_test.go b/cli/command/checkpoint/list_test.go index 8e1008b7b1..b7947e9eee 100644 --- a/cli/command/checkpoint/list_test.go +++ b/cli/command/checkpoint/list_test.go @@ -41,7 +41,7 @@ func TestCheckpointListErrors(t *testing.T) { }) cmd := newListCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/checkpoint/remove_test.go b/cli/command/checkpoint/remove_test.go index b941581341..1f340a8c60 100644 --- a/cli/command/checkpoint/remove_test.go +++ b/cli/command/checkpoint/remove_test.go @@ -40,7 +40,7 @@ func TestCheckpointRemoveErrors(t *testing.T) { }) cmd := newRemoveCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/cli.go b/cli/command/cli.go index 235200c63a..37a45494e6 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -118,7 +118,7 @@ func (cli *DockerCli) In() *streams.In { // ShowHelp shows the command help. func ShowHelp(err io.Writer) func(*cobra.Command, []string) error { return func(cmd *cobra.Command, args []string) error { - cmd.SetOutput(err) + cmd.SetOut(err) cmd.HelpFunc()(cmd, args) return nil } diff --git a/cli/command/config/create_test.go b/cli/command/config/create_test.go index 062f676536..e132651bb8 100644 --- a/cli/command/config/create_test.go +++ b/cli/command/config/create_test.go @@ -46,7 +46,7 @@ func TestConfigCreateErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/config/inspect_test.go b/cli/command/config/inspect_test.go index 67cf056376..6ac3a442ec 100644 --- a/cli/command/config/inspect_test.go +++ b/cli/command/config/inspect_test.go @@ -59,7 +59,7 @@ func TestConfigInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/config/ls_test.go b/cli/command/config/ls_test.go index 78c4d54f45..fcc5a62851 100644 --- a/cli/command/config/ls_test.go +++ b/cli/command/config/ls_test.go @@ -40,7 +40,7 @@ func TestConfigListErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/config/remove_test.go b/cli/command/config/remove_test.go index b7676d2e3b..19a92dc407 100644 --- a/cli/command/config/remove_test.go +++ b/cli/command/config/remove_test.go @@ -36,7 +36,7 @@ func TestConfigRemoveErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -73,7 +73,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) { cmd := newConfigRemoveCommand(cli) cmd.SetArgs(names) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), "error removing config: foo") assert.Check(t, is.DeepEqual(names, removedConfigs)) } diff --git a/cli/command/container/attach_test.go b/cli/command/container/attach_test.go index 37b5066023..7790f351c9 100644 --- a/cli/command/container/attach_test.go +++ b/cli/command/container/attach_test.go @@ -71,7 +71,7 @@ func TestNewAttachCommandErrors(t *testing.T) { } for _, tc := range testCases { cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index b112293234..4e0bfa07ca 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -191,7 +191,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) { }, test.EnableContentTrust) cli.SetNotaryClient(tc.notaryFunc) cmd := NewCreateCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.ErrorContains(t, err, tc.expectedError) @@ -250,7 +250,7 @@ func TestNewCreateCommandWithWarnings(t *testing.T) { }, }) cmd := NewCreateCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) @@ -298,7 +298,7 @@ func TestCreateContainerWithProxyConfig(t *testing.T) { }, }) cmd := NewCreateCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"image:tag"}) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/container/exec_test.go b/cli/command/container/exec_test.go index 80cb985618..ce10b334e9 100644 --- a/cli/command/container/exec_test.go +++ b/cli/command/container/exec_test.go @@ -220,7 +220,7 @@ func TestNewExecCommandErrors(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}) cmd := NewExecCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } diff --git a/cli/command/container/export_test.go b/cli/command/container/export_test.go index 7ebc3d41b3..30e80730bf 100644 --- a/cli/command/container/export_test.go +++ b/cli/command/container/export_test.go @@ -21,7 +21,7 @@ func TestContainerExportOutputToFile(t *testing.T) { }, }) cmd := NewExportCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"}) assert.NilError(t, cmd.Execute()) @@ -39,7 +39,7 @@ func TestContainerExportOutputToIrregularFile(t *testing.T) { }, }) cmd := NewExportCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"-o", "/dev/random", "container"}) err := cmd.Execute() diff --git a/cli/command/container/list_test.go b/cli/command/container/list_test.go index 5ecb15be9c..0c33d048b8 100644 --- a/cli/command/container/list_test.go +++ b/cli/command/container/list_test.go @@ -161,7 +161,7 @@ func TestContainerListErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/container/run_test.go b/cli/command/container/run_test.go index 268e76c1e0..8c5f3c3d85 100644 --- a/cli/command/container/run_test.go +++ b/cli/command/container/run_test.go @@ -66,7 +66,7 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) { cli.SetNotaryClient(tc.notaryFunc) cmd := NewRunCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err := cmd.Execute() assert.Assert(t, err != nil) assert.Assert(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError)) diff --git a/cli/command/image/build_test.go b/cli/command/image/build_test.go index 3c8c875eb9..0b2ee52cc0 100644 --- a/cli/command/image/build_test.go +++ b/cli/command/image/build_test.go @@ -130,7 +130,7 @@ func TestRunBuildFromGitHubSpecialCase(t *testing.T) { cmd := NewBuildCommand(test.NewFakeCli(&fakeClient{})) // Clone a small repo that exists so git doesn't prompt for credentials cmd.SetArgs([]string{"github.com/docker/for-win"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err := cmd.Execute() assert.ErrorContains(t, err, "unable to prepare context") assert.ErrorContains(t, err, "docker-build-git") @@ -154,7 +154,7 @@ func TestRunBuildFromLocalGitHubDir(t *testing.T) { client := test.NewFakeCli(&fakeClient{}) cmd := NewBuildCommand(client) cmd.SetArgs([]string{buildDir}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err = cmd.Execute() assert.NilError(t, err) } diff --git a/cli/command/image/history_test.go b/cli/command/image/history_test.go index 90cceac586..7916f895e6 100644 --- a/cli/command/image/history_test.go +++ b/cli/command/image/history_test.go @@ -37,7 +37,7 @@ func TestNewHistoryCommandErrors(t *testing.T) { } for _, tc := range testCases { cmd := NewHistoryCommand(test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -95,7 +95,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc}) cmd := NewHistoryCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/image/import_test.go b/cli/command/image/import_test.go index 6f5e338da0..94e7d723aa 100644 --- a/cli/command/image/import_test.go +++ b/cli/command/image/import_test.go @@ -36,7 +36,7 @@ func TestNewImportCommandErrors(t *testing.T) { } for _, tc := range testCases { cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -44,7 +44,7 @@ func TestNewImportCommandErrors(t *testing.T) { func TestNewImportCommandInvalidFile(t *testing.T) { cmd := NewImportCommand(test.NewFakeCli(&fakeClient{})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"testdata/import-command-success.unexistent-file"}) assert.ErrorContains(t, cmd.Execute(), "testdata/import-command-success.unexistent-file") } @@ -90,7 +90,7 @@ func TestNewImportCommandSuccess(t *testing.T) { } for _, tc := range testCases { cmd := NewImportCommand(test.NewFakeCli(&fakeClient{imageImportFunc: tc.imageImportFunc})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.NilError(t, cmd.Execute()) } diff --git a/cli/command/image/inspect_test.go b/cli/command/image/inspect_test.go index 1f41d8779d..fac74c7e03 100644 --- a/cli/command/image/inspect_test.go +++ b/cli/command/image/inspect_test.go @@ -26,7 +26,7 @@ func TestNewInspectCommandErrors(t *testing.T) { } for _, tc := range testCases { cmd := newInspectCommand(test.NewFakeCli(&fakeClient{})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -78,7 +78,7 @@ func TestNewInspectCommandSuccess(t *testing.T) { imageInspectInvocationCount = 0 cli := test.NewFakeCli(&fakeClient{imageInspectFunc: tc.imageInspectFunc}) cmd := newInspectCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/image/list_test.go b/cli/command/image/list_test.go index e23c38b899..a78f1d49af 100644 --- a/cli/command/image/list_test.go +++ b/cli/command/image/list_test.go @@ -36,7 +36,7 @@ func TestNewImagesCommandErrors(t *testing.T) { } for _, tc := range testCases { cmd := NewImagesCommand(test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -82,7 +82,7 @@ func TestNewImagesCommandSuccess(t *testing.T) { cli := test.NewFakeCli(&fakeClient{imageListFunc: tc.imageListFunc}) cli.SetConfigFile(&configfile.ConfigFile{ImagesFormat: tc.imageFormat}) cmd := NewImagesCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/image/load_test.go b/cli/command/image/load_test.go index eea3d31ee1..d1afb46139 100644 --- a/cli/command/image/load_test.go +++ b/cli/command/image/load_test.go @@ -44,7 +44,7 @@ func TestNewLoadCommandErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc}) cli.In().SetIsTerminal(tc.isTerminalIn) cmd := NewLoadCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -53,7 +53,7 @@ func TestNewLoadCommandErrors(t *testing.T) { func TestNewLoadCommandInvalidInput(t *testing.T) { expectedError := "open *" cmd := NewLoadCommand(test.NewFakeCli(&fakeClient{})) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"--input", "*"}) err := cmd.Execute() assert.ErrorContains(t, err, expectedError) @@ -92,7 +92,7 @@ func TestNewLoadCommandSuccess(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{imageLoadFunc: tc.imageLoadFunc}) cmd := NewLoadCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/image/prune_test.go b/cli/command/image/prune_test.go index 2ff5c81e35..cbfb1b5bab 100644 --- a/cli/command/image/prune_test.go +++ b/cli/command/image/prune_test.go @@ -39,7 +39,7 @@ func TestNewPruneCommandErrors(t *testing.T) { cmd := NewPruneCommand(test.NewFakeCli(&fakeClient{ imagesPruneFunc: tc.imagesPruneFunc, })) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -93,7 +93,7 @@ func TestNewPruneCommandSuccess(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{imagesPruneFunc: tc.imagesPruneFunc}) cmd := NewPruneCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) diff --git a/cli/command/image/pull_test.go b/cli/command/image/pull_test.go index 36af9c6e5c..b9d49701b6 100644 --- a/cli/command/image/pull_test.go +++ b/cli/command/image/pull_test.go @@ -40,7 +40,7 @@ func TestNewPullCommandErrors(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{}) cmd := NewPullCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -76,7 +76,7 @@ func TestNewPullCommandSuccess(t *testing.T) { }, }) cmd := NewPullCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.NilError(t, err) @@ -118,7 +118,7 @@ func TestNewPullCommandWithContentTrustErrors(t *testing.T) { }, test.EnableContentTrust) cli.SetNotaryClient(tc.notaryFunc) cmd := NewPullCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() assert.ErrorContains(t, err, tc.expectedError) diff --git a/cli/command/image/push_test.go b/cli/command/image/push_test.go index aad358c441..963636980b 100644 --- a/cli/command/image/push_test.go +++ b/cli/command/image/push_test.go @@ -41,7 +41,7 @@ func TestNewPushCommandErrors(t *testing.T) { for _, tc := range testCases { cli := test.NewFakeCli(&fakeClient{imagePushFunc: tc.imagePushFunc}) cmd := NewPushCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -73,7 +73,7 @@ func TestNewPushCommandSuccess(t *testing.T) { }, }) cmd := NewPushCommand(cli) - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) cmd.SetArgs(tc.args) assert.NilError(t, cmd.Execute()) if tc.output != "" { diff --git a/cli/command/image/remove_test.go b/cli/command/image/remove_test.go index bdcfedbf06..0dc1944477 100644 --- a/cli/command/image/remove_test.go +++ b/cli/command/image/remove_test.go @@ -68,7 +68,7 @@ func TestNewRemoveCommandErrors(t *testing.T) { cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{ imageRemoveFunc: tc.imageRemoveFunc, })) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) }) @@ -124,7 +124,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) { t.Run(tc.name, func(t *testing.T) { cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc}) cmd := NewRemoveCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Equal(tc.expectedStderr, cli.ErrBuffer().String())) diff --git a/cli/command/image/save_test.go b/cli/command/image/save_test.go index 5e3f8e271c..eb0fbc3bdd 100644 --- a/cli/command/image/save_test.go +++ b/cli/command/image/save_test.go @@ -56,7 +56,7 @@ func TestNewSaveCommandErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{imageSaveFunc: tc.imageSaveFunc}) cli.Out().SetIsTerminal(tc.isTerminal) cmd := NewSaveCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -98,7 +98,7 @@ func TestNewSaveCommandSuccess(t *testing.T) { return ioutil.NopCloser(strings.NewReader("")), nil }, })) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(tc.args) assert.NilError(t, cmd.Execute()) if tc.deferredFunc != nil { diff --git a/cli/command/image/tag_test.go b/cli/command/image/tag_test.go index bb62a5aba2..b044ae22cb 100644 --- a/cli/command/image/tag_test.go +++ b/cli/command/image/tag_test.go @@ -19,7 +19,7 @@ func TestCliNewTagCommandErrors(t *testing.T) { for _, args := range testCases { cmd := NewTagCommand(test.NewFakeCli(&fakeClient{})) cmd.SetArgs(args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), expectedError) } } @@ -34,7 +34,7 @@ func TestCliNewTagCommand(t *testing.T) { }, })) cmd.SetArgs([]string{"image1", "image2"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.NilError(t, cmd.Execute()) value, _ := cmd.Flags().GetBool("interspersed") assert.Check(t, !value) diff --git a/cli/command/manifest/annotate_test.go b/cli/command/manifest/annotate_test.go index a362d53a34..bf7339295f 100644 --- a/cli/command/manifest/annotate_test.go +++ b/cli/command/manifest/annotate_test.go @@ -33,7 +33,7 @@ func TestManifestAnnotateError(t *testing.T) { cli := test.NewFakeCli(nil) cmd := newAnnotateCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -51,7 +51,7 @@ func TestManifestAnnotate(t *testing.T) { cmd := newAnnotateCommand(cli) cmd.SetArgs([]string{"example.com/list:v1", "example.com/fake:0.0"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) expectedError := "manifest for image example.com/fake:0.0 does not exist" assert.ErrorContains(t, cmd.Execute(), expectedError) diff --git a/cli/command/manifest/create_test.go b/cli/command/manifest/create_test.go index 14222dc262..b6014f8bef 100644 --- a/cli/command/manifest/create_test.go +++ b/cli/command/manifest/create_test.go @@ -33,7 +33,7 @@ func TestManifestCreateErrors(t *testing.T) { cli := test.NewFakeCli(nil) cmd := newCreateListCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -58,7 +58,7 @@ func TestManifestCreateAmend(t *testing.T) { cmd := newCreateListCommand(cli) cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.1"}) cmd.Flags().Set("amend", "true") - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err = cmd.Execute() assert.NilError(t, err) @@ -87,7 +87,7 @@ func TestManifestCreateRefuseAmend(t *testing.T) { cmd := newCreateListCommand(cli) cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err = cmd.Execute() assert.Error(t, err, "refusing to amend an existing manifest list with no --amend flag") } @@ -110,7 +110,7 @@ func TestManifestCreateNoManifest(t *testing.T) { cmd := newCreateListCommand(cli) cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err := cmd.Execute() assert.Error(t, err, "No such image: example.com/alpine:3.0") } diff --git a/cli/command/manifest/inspect_test.go b/cli/command/manifest/inspect_test.go index 2c506841e8..f58c00c865 100644 --- a/cli/command/manifest/inspect_test.go +++ b/cli/command/manifest/inspect_test.go @@ -77,7 +77,7 @@ func TestInspectCommandLocalManifestNotFound(t *testing.T) { cli.SetManifestStore(store) cmd := newInspectCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"}) err := cmd.Execute() assert.Error(t, err, "No such manifest: example.com/alpine:3.0") @@ -99,7 +99,7 @@ func TestInspectCommandNotFound(t *testing.T) { }) cmd := newInspectCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"example.com/alpine:3.0"}) err := cmd.Execute() assert.Error(t, err, "No such manifest: example.com/alpine:3.0") @@ -137,7 +137,7 @@ func TestInspectcommandRemoteManifest(t *testing.T) { }) cmd := newInspectCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"example.com/alpine:3.0"}) assert.NilError(t, cmd.Execute()) actual := cli.OutBuffer() diff --git a/cli/command/manifest/push_test.go b/cli/command/manifest/push_test.go index 311c3e3490..5146c85b5c 100644 --- a/cli/command/manifest/push_test.go +++ b/cli/command/manifest/push_test.go @@ -42,7 +42,7 @@ func TestManifestPushErrors(t *testing.T) { cli := test.NewFakeCli(nil) cmd := newPushListCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/network/connect_test.go b/cli/command/network/connect_test.go index 1a6958aa8e..bc1432b625 100644 --- a/cli/command/network/connect_test.go +++ b/cli/command/network/connect_test.go @@ -37,7 +37,7 @@ func TestNetworkConnectErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } diff --git a/cli/command/network/create_test.go b/cli/command/network/create_test.go index 354184f3d4..307b5a1487 100644 --- a/cli/command/network/create_test.go +++ b/cli/command/network/create_test.go @@ -137,7 +137,7 @@ func TestNetworkCreateErrors(t *testing.T) { for key, value := range tc.flags { assert.NilError(t, cmd.Flags().Set(key, value)) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } diff --git a/cli/command/network/disconnect_test.go b/cli/command/network/disconnect_test.go index 01bca76510..4413b95e51 100644 --- a/cli/command/network/disconnect_test.go +++ b/cli/command/network/disconnect_test.go @@ -35,7 +35,7 @@ func TestNetworkDisconnectErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/network/list_test.go b/cli/command/network/list_test.go index 9955a525fc..0cb3b04975 100644 --- a/cli/command/network/list_test.go +++ b/cli/command/network/list_test.go @@ -35,7 +35,7 @@ func TestNetworkListErrors(t *testing.T) { networkListFunc: tc.networkListFunc, }), ) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/demote_test.go b/cli/command/node/demote_test.go index 09e067edeb..c4d6c26769 100644 --- a/cli/command/node/demote_test.go +++ b/cli/command/node/demote_test.go @@ -43,7 +43,7 @@ func TestNodeDemoteErrors(t *testing.T) { nodeUpdateFunc: tc.nodeUpdateFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/inspect_test.go b/cli/command/node/inspect_test.go index f73df761dd..975db14b7c 100644 --- a/cli/command/node/inspect_test.go +++ b/cli/command/node/inspect_test.go @@ -73,7 +73,7 @@ func TestNodeInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/list_test.go b/cli/command/node/list_test.go index 02fedcd191..309bd3798a 100644 --- a/cli/command/node/list_test.go +++ b/cli/command/node/list_test.go @@ -47,7 +47,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) { infoFunc: tc.infoFunc, }) cmd := newListCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/promote_test.go b/cli/command/node/promote_test.go index a0f7b465e2..68299d2983 100644 --- a/cli/command/node/promote_test.go +++ b/cli/command/node/promote_test.go @@ -43,7 +43,7 @@ func TestNodePromoteErrors(t *testing.T) { nodeUpdateFunc: tc.nodeUpdateFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/ps_test.go b/cli/command/node/ps_test.go index 120d59c247..2b6ab9a7a1 100644 --- a/cli/command/node/ps_test.go +++ b/cli/command/node/ps_test.go @@ -59,7 +59,7 @@ func TestNodePsErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/remove_test.go b/cli/command/node/remove_test.go index 5c91ec538a..e4eaf9df71 100644 --- a/cli/command/node/remove_test.go +++ b/cli/command/node/remove_test.go @@ -32,7 +32,7 @@ func TestNodeRemoveErrors(t *testing.T) { nodeRemoveFunc: tc.nodeRemoveFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/node/update_test.go b/cli/command/node/update_test.go index 70d2d02347..879855bfab 100644 --- a/cli/command/node/update_test.go +++ b/cli/command/node/update_test.go @@ -63,7 +63,7 @@ func TestNodeUpdateErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/plugin/create_test.go b/cli/command/plugin/create_test.go index b327f606ce..923f931beb 100644 --- a/cli/command/plugin/create_test.go +++ b/cli/command/plugin/create_test.go @@ -41,7 +41,7 @@ func TestCreateErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -53,7 +53,7 @@ func TestCreateErrorOnFileAsContextDir(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpFile.Path()}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "context must be a directory") } @@ -64,7 +64,7 @@ func TestCreateErrorOnContextDirWithoutConfig(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) expectedErr := "config.json: no such file or directory" if runtime.GOOS == "windows" { @@ -82,7 +82,7 @@ func TestCreateErrorOnInvalidConfig(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "invalid") } @@ -100,7 +100,7 @@ func TestCreateErrorFromDaemon(t *testing.T) { cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "Error creating plugin") } diff --git a/cli/command/plugin/disable_test.go b/cli/command/plugin/disable_test.go index ab8b6ccea6..bd1f812339 100644 --- a/cli/command/plugin/disable_test.go +++ b/cli/command/plugin/disable_test.go @@ -40,7 +40,7 @@ func TestPluginDisableErrors(t *testing.T) { pluginDisableFunc: tc.pluginDisableFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/plugin/enable_test.go b/cli/command/plugin/enable_test.go index d8aa421ffc..5652543b70 100644 --- a/cli/command/plugin/enable_test.go +++ b/cli/command/plugin/enable_test.go @@ -51,7 +51,7 @@ func TestPluginEnableErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/plugin/inspect_test.go b/cli/command/plugin/inspect_test.go index e9e34ed38c..a112cd42a6 100644 --- a/cli/command/plugin/inspect_test.go +++ b/cli/command/plugin/inspect_test.go @@ -73,7 +73,7 @@ func TestInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) }) } diff --git a/cli/command/plugin/install_test.go b/cli/command/plugin/install_test.go index 4180a0bfc2..1e6486a013 100644 --- a/cli/command/plugin/install_test.go +++ b/cli/command/plugin/install_test.go @@ -58,7 +58,7 @@ func TestInstallErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc}) cmd := newInstallCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -100,7 +100,7 @@ func TestInstallContentTrustErrors(t *testing.T) { cli.SetNotaryClient(tc.notaryFunc) cmd := newInstallCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/plugin/list_test.go b/cli/command/plugin/list_test.go index 2a86a6b86e..fe9bd9762a 100644 --- a/cli/command/plugin/list_test.go +++ b/cli/command/plugin/list_test.go @@ -52,7 +52,7 @@ func TestListErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/plugin/remove_test.go b/cli/command/plugin/remove_test.go index 877483ddbf..f436c5accd 100644 --- a/cli/command/plugin/remove_test.go +++ b/cli/command/plugin/remove_test.go @@ -37,7 +37,7 @@ func TestRemoveErrors(t *testing.T) { }) cmd := newRemoveCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/secret/create_test.go b/cli/command/secret/create_test.go index a7bdb6b592..5d12b84c71 100644 --- a/cli/command/secret/create_test.go +++ b/cli/command/secret/create_test.go @@ -44,7 +44,7 @@ func TestSecretCreateErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/secret/inspect_test.go b/cli/command/secret/inspect_test.go index e50272f0d8..d4eda421df 100644 --- a/cli/command/secret/inspect_test.go +++ b/cli/command/secret/inspect_test.go @@ -59,7 +59,7 @@ func TestSecretInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/secret/ls_test.go b/cli/command/secret/ls_test.go index 35cc4e3974..bfc1f3c4ff 100644 --- a/cli/command/secret/ls_test.go +++ b/cli/command/secret/ls_test.go @@ -40,7 +40,7 @@ func TestSecretListErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/secret/remove_test.go b/cli/command/secret/remove_test.go index b91a891f33..a52e5d1f74 100644 --- a/cli/command/secret/remove_test.go +++ b/cli/command/secret/remove_test.go @@ -36,7 +36,7 @@ func TestSecretRemoveErrors(t *testing.T) { }), ) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -72,7 +72,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) { }) cmd := newSecretRemoveCommand(cli) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs(names) assert.Error(t, cmd.Execute(), "error removing secret: foo") assert.Check(t, is.DeepEqual(names, removedSecrets)) diff --git a/cli/command/service/rollback_test.go b/cli/command/service/rollback_test.go index 9c3a8d4461..a4da2b54fd 100644 --- a/cli/command/service/rollback_test.go +++ b/cli/command/service/rollback_test.go @@ -49,7 +49,7 @@ func TestRollback(t *testing.T) { cmd := newRollbackCommand(cli) cmd.SetArgs(tc.args) cmd.Flags().Set("quiet", "true") - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Equal(strings.TrimSpace(cli.ErrBuffer().String()), tc.expectedDockerCliErr)) } @@ -98,7 +98,7 @@ func TestRollbackWithErrors(t *testing.T) { })) cmd.SetArgs(tc.args) cmd.Flags().Set("quiet", "true") - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/stack/deploy_test.go b/cli/command/stack/deploy_test.go index aa05d25016..cc27e12f68 100644 --- a/cli/command/stack/deploy_test.go +++ b/cli/command/stack/deploy_test.go @@ -11,7 +11,7 @@ import ( func TestDeployWithEmptyName(t *testing.T) { cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}), nil) cmd.SetArgs([]string{"' '"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`) } diff --git a/cli/command/stack/list_test.go b/cli/command/stack/list_test.go index e898190e5b..a6983cc3a6 100644 --- a/cli/command/stack/list_test.go +++ b/cli/command/stack/list_test.go @@ -54,7 +54,7 @@ func TestListErrors(t *testing.T) { serviceListFunc: tc.serviceListFunc, }), &orchestrator) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) for key, value := range tc.flags { cmd.Flags().Set(key, value) } diff --git a/cli/command/stack/ps_test.go b/cli/command/stack/ps_test.go index 37b0007b3c..58a651252b 100644 --- a/cli/command/stack/ps_test.go +++ b/cli/command/stack/ps_test.go @@ -45,7 +45,7 @@ func TestStackPsErrors(t *testing.T) { taskListFunc: tc.taskListFunc, }), &orchestrator) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -169,7 +169,7 @@ func TestStackPs(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) if tc.expectedErr != "" { assert.Error(t, cmd.Execute(), tc.expectedErr) diff --git a/cli/command/stack/remove_test.go b/cli/command/stack/remove_test.go index a9622647be..0f10c55b24 100644 --- a/cli/command/stack/remove_test.go +++ b/cli/command/stack/remove_test.go @@ -44,7 +44,7 @@ func fakeClientForRemoveStackTest(version string) *fakeClient { func TestRemoveWithEmptyName(t *testing.T) { cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}), &orchestrator) cmd.SetArgs([]string{"good", "' '", "alsogood"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`) } @@ -155,7 +155,7 @@ func TestRemoveContinueAfterError(t *testing.T) { }, } cmd := newRemoveCommand(test.NewFakeCli(cli), &orchestrator) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.SetArgs([]string{"foo", "bar"}) assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo") diff --git a/cli/command/stack/services_test.go b/cli/command/stack/services_test.go index da3355e961..ef190d2290 100644 --- a/cli/command/stack/services_test.go +++ b/cli/command/stack/services_test.go @@ -79,7 +79,7 @@ func TestStackServicesErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) }) } @@ -88,7 +88,7 @@ func TestStackServicesErrors(t *testing.T) { func TestRunServicesWithEmptyName(t *testing.T) { cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}), &orchestrator) cmd.SetArgs([]string{"' '"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`) } diff --git a/cli/command/swarm/ca_test.go b/cli/command/swarm/ca_test.go index d20dccfc65..e9fafcaf71 100644 --- a/cli/command/swarm/ca_test.go +++ b/cli/command/swarm/ca_test.go @@ -145,7 +145,7 @@ func TestDisplayTrustRootInvalidFlags(t *testing.T) { }, })) assert.Check(t, cmd.Flags().Parse(testCase.args)) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), testCase.errorMsg) } } @@ -187,7 +187,7 @@ func TestUpdateSwarmSpecDefaultRotate(t *testing.T) { }) cmd := newCACommand(cli) cmd.SetArgs([]string{"--rotate", "--detach"}) - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) assert.NilError(t, cmd.Execute()) expected := swarmSpecWithFullCAConfig() @@ -218,7 +218,7 @@ func TestUpdateSwarmSpecCertAndKey(t *testing.T) { "--ca-cert=" + certfile, "--ca-key=" + keyfile, "--cert-expiry=3m"}) - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) assert.NilError(t, cmd.Execute()) expected := swarmSpecWithFullCAConfig() @@ -244,7 +244,7 @@ func TestUpdateSwarmSpecCertAndExternalCA(t *testing.T) { "--detach", "--ca-cert=" + certfile, "--external-ca=protocol=cfssl,url=https://some.external.ca"}) - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) assert.NilError(t, cmd.Execute()) expected := swarmSpecWithFullCAConfig() @@ -282,7 +282,7 @@ func TestUpdateSwarmSpecCertAndKeyAndExternalCA(t *testing.T) { "--ca-cert=" + certfile, "--ca-key=" + keyfile, "--external-ca=protocol=cfssl,url=https://some.external.ca"}) - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) assert.NilError(t, cmd.Execute()) expected := swarmSpecWithFullCAConfig() diff --git a/cli/command/swarm/init_test.go b/cli/command/swarm/init_test.go index 527ce3622d..2614177269 100644 --- a/cli/command/swarm/init_test.go +++ b/cli/command/swarm/init_test.go @@ -73,7 +73,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/join_test.go b/cli/command/swarm/join_test.go index 3ef970bfa6..7fba3bc4d7 100644 --- a/cli/command/swarm/join_test.go +++ b/cli/command/swarm/join_test.go @@ -54,7 +54,7 @@ func TestSwarmJoinErrors(t *testing.T) { infoFunc: tc.infoFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/join_token_test.go b/cli/command/swarm/join_token_test.go index 1a315f355b..3d79ae90ba 100644 --- a/cli/command/swarm/join_token_test.go +++ b/cli/command/swarm/join_token_test.go @@ -98,7 +98,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/leave_test.go b/cli/command/swarm/leave_test.go index 288363b342..969bdbbfb4 100644 --- a/cli/command/swarm/leave_test.go +++ b/cli/command/swarm/leave_test.go @@ -37,7 +37,7 @@ func TestSwarmLeaveErrors(t *testing.T) { swarmLeaveFunc: tc.swarmLeaveFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/unlock_key_test.go b/cli/command/swarm/unlock_key_test.go index 72ad2bbc36..e51bd726ef 100644 --- a/cli/command/swarm/unlock_key_test.go +++ b/cli/command/swarm/unlock_key_test.go @@ -90,7 +90,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/unlock_test.go b/cli/command/swarm/unlock_test.go index e106e4ed14..6d40613619 100644 --- a/cli/command/swarm/unlock_test.go +++ b/cli/command/swarm/unlock_test.go @@ -70,7 +70,7 @@ func TestSwarmUnlockErrors(t *testing.T) { swarmUnlockFunc: tc.swarmUnlockFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/swarm/update_test.go b/cli/command/swarm/update_test.go index 852201cc0e..ea695f2588 100644 --- a/cli/command/swarm/update_test.go +++ b/cli/command/swarm/update_test.go @@ -75,7 +75,7 @@ func TestSwarmUpdateErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -176,7 +176,7 @@ func TestSwarmUpdate(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(cli.OutBuffer()) + cmd.SetOut(cli.OutBuffer()) assert.NilError(t, cmd.Execute()) golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("update-%s.golden", tc.name)) } diff --git a/cli/command/system/version_test.go b/cli/command/system/version_test.go index 482c6ce24d..eafaa7ee6e 100644 --- a/cli/command/system/version_test.go +++ b/cli/command/system/version_test.go @@ -21,7 +21,7 @@ func TestVersionWithoutServer(t *testing.T) { }, }) cmd := NewVersionCommand(cli) - cmd.SetOutput(cli.Err()) + cmd.SetOut(cli.Err()) assert.ErrorContains(t, cmd.Execute(), "no server") out := cli.OutBuffer().String() // TODO: use an assertion like e2e/image/build_test.go:assertBuildOutput() diff --git a/cli/command/trust/inspect_pretty_test.go b/cli/command/trust/inspect_pretty_test.go index 8afcb4c7e2..ef1fc84ba3 100644 --- a/cli/command/trust/inspect_pretty_test.go +++ b/cli/command/trust/inspect_pretty_test.go @@ -65,7 +65,7 @@ func TestTrustInspectPrettyCommandErrors(t *testing.T) { cmd := newInspectCommand( test.NewFakeCli(&fakeClient{})) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.Flags().Set("pretty", "true") assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } @@ -77,7 +77,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) { cmd := newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"nonexistent-reg-name.io/image"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image") cli = test.NewFakeCli(&fakeClient{}) @@ -85,7 +85,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) { cmd = newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"nonexistent-reg-name.io/image:tag"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image") } @@ -95,7 +95,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) { cmd := newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/unsigned-img"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img") cli = test.NewFakeCli(&fakeClient{}) @@ -103,7 +103,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) { cmd = newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/unsigned-img:tag"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img:tag") } @@ -113,7 +113,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) { cmd := newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/img:unsigned-tag"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img:unsigned-tag")) assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img")) @@ -123,7 +123,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) { cmd = newInspectCommand(cli) cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/img"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.NilError(t, cmd.Execute()) assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img")) assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img")) diff --git a/cli/command/trust/inspect_test.go b/cli/command/trust/inspect_test.go index 0700952d67..e3c79364ca 100644 --- a/cli/command/trust/inspect_test.go +++ b/cli/command/trust/inspect_test.go @@ -38,7 +38,7 @@ func TestTrustInspectCommandErrors(t *testing.T) { test.NewFakeCli(&fakeClient{})) cmd.Flags().Set("pretty", "true") cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -85,7 +85,7 @@ func TestTrustInspectCommandRepositoryErrors(t *testing.T) { cli.SetNotaryClient(tc.notaryRepository) cmd := newInspectCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.err) if tc.golden != "" { golden.Assert(t, cli.OutBuffer().String(), tc.golden) diff --git a/cli/command/trust/key_generate_test.go b/cli/command/trust/key_generate_test.go index aa61f3e793..4e3083e1af 100644 --- a/cli/command/trust/key_generate_test.go +++ b/cli/command/trust/key_generate_test.go @@ -44,7 +44,7 @@ func TestTrustKeyGenerateErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newKeyGenerateCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/trust/key_load_test.go b/cli/command/trust/key_load_test.go index d0fd466c3f..89386a319b 100644 --- a/cli/command/trust/key_load_test.go +++ b/cli/command/trust/key_load_test.go @@ -65,7 +65,7 @@ func TestTrustKeyLoadErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newKeyLoadCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) assert.Check(t, is.Contains(cli.OutBuffer().String(), tc.expectedOutput)) } diff --git a/cli/command/trust/revoke_test.go b/cli/command/trust/revoke_test.go index f0182c248b..bd550a7d27 100644 --- a/cli/command/trust/revoke_test.go +++ b/cli/command/trust/revoke_test.go @@ -50,7 +50,7 @@ func TestTrustRevokeCommandErrors(t *testing.T) { cmd := newRevokeCommand( test.NewFakeCli(&fakeClient{})) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -131,7 +131,7 @@ func TestTrustRevokeCommand(t *testing.T) { cli.SetNotaryClient(tc.notaryRepository) cmd := newRevokeCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) if tc.expectedErr != "" { assert.ErrorContains(t, cmd.Execute(), tc.expectedErr) return diff --git a/cli/command/trust/sign_test.go b/cli/command/trust/sign_test.go index 38d7d63610..2570414086 100644 --- a/cli/command/trust/sign_test.go +++ b/cli/command/trust/sign_test.go @@ -70,7 +70,7 @@ func TestTrustSignCommandErrors(t *testing.T) { cmd := newSignCommand( test.NewFakeCli(&fakeClient{})) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -80,7 +80,7 @@ func TestTrustSignCommandOfflineErrors(t *testing.T) { cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository) cmd := newSignCommand(cli) cmd.SetArgs([]string{"reg-name.io/image:tag"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "client is offline") } @@ -286,7 +286,7 @@ func TestSignCommandChangeListIsCleanedOnError(t *testing.T) { cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository) cmd := newSignCommand(cli) cmd.SetArgs([]string{"ubuntu:latest"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err = cmd.Execute() assert.Assert(t, err != nil) @@ -303,7 +303,7 @@ func TestSignCommandLocalFlag(t *testing.T) { cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository) cmd := newSignCommand(cli) cmd.SetArgs([]string{"--local", "reg-name.io/image:red"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), "error contacting notary server: dial tcp: lookup reg-name.io") } diff --git a/cli/command/trust/signer_add_test.go b/cli/command/trust/signer_add_test.go index f7a3dbd198..d487883d35 100644 --- a/cli/command/trust/signer_add_test.go +++ b/cli/command/trust/signer_add_test.go @@ -62,7 +62,7 @@ func TestTrustSignerAddErrors(t *testing.T) { cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository) cmd := newSignerAddCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -82,7 +82,7 @@ func TestSignerAddCommandNoTargetsKey(t *testing.T) { cmd := newSignerAddCommand(cli) cmd.SetArgs([]string{"--key", tmpfile.Name(), "alice", "alpine", "linuxkit/alpine"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), fmt.Sprintf("could not parse public key from file: %s: no valid public key found", tmpfile.Name())) } @@ -97,7 +97,7 @@ func TestSignerAddCommandBadKeyPath(t *testing.T) { cmd := newSignerAddCommand(cli) cmd.SetArgs([]string{"--key", "/path/to/key.pem", "alice", "alpine"}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) expectedError := "unable to read public key from file: open /path/to/key.pem: no such file or directory" if runtime.GOOS == "windows" { expectedError = "unable to read public key from file: open /path/to/key.pem: The system cannot find the path specified." @@ -123,7 +123,7 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) { imageName := "870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd" cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName}) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.Error(t, cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd") expectedErr := fmt.Sprintf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings\n\n", imageName) diff --git a/cli/command/trust/signer_remove_test.go b/cli/command/trust/signer_remove_test.go index 1a529fe78a..44fddce0e5 100644 --- a/cli/command/trust/signer_remove_test.go +++ b/cli/command/trust/signer_remove_test.go @@ -32,7 +32,7 @@ func TestTrustSignerRemoveErrors(t *testing.T) { cmd := newSignerRemoveCommand( test.NewFakeCli(&fakeClient{})) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } testCasesWithOutput := []struct { @@ -61,7 +61,7 @@ func TestTrustSignerRemoveErrors(t *testing.T) { cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository) cmd := newSignerRemoveCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) cmd.Execute() assert.Check(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError)) } diff --git a/cli/command/volume/create_test.go b/cli/command/volume/create_test.go index 7fab40e4a1..0b1562a75f 100644 --- a/cli/command/volume/create_test.go +++ b/cli/command/volume/create_test.go @@ -49,7 +49,7 @@ func TestVolumeCreateErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/inspect_test.go b/cli/command/volume/inspect_test.go index 2dfce9102c..563e92202e 100644 --- a/cli/command/volume/inspect_test.go +++ b/cli/command/volume/inspect_test.go @@ -60,7 +60,7 @@ func TestVolumeInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/list_test.go b/cli/command/volume/list_test.go index 6f61291bf8..2c1501e5c7 100644 --- a/cli/command/volume/list_test.go +++ b/cli/command/volume/list_test.go @@ -43,7 +43,7 @@ func TestVolumeListErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/prune_test.go b/cli/command/volume/prune_test.go index 0c9d51fe51..8e668c57f6 100644 --- a/cli/command/volume/prune_test.go +++ b/cli/command/volume/prune_test.go @@ -48,7 +48,7 @@ func TestVolumePruneErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/command/volume/remove_test.go b/cli/command/volume/remove_test.go index 2f7769d3a3..19bc467d70 100644 --- a/cli/command/volume/remove_test.go +++ b/cli/command/volume/remove_test.go @@ -32,7 +32,7 @@ func TestVolumeRemoveErrors(t *testing.T) { volumeRemoveFunc: tc.volumeRemoveFunc, })) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } diff --git a/cli/required_test.go b/cli/required_test.go index f13d26c969..d83c2cb4d9 100644 --- a/cli/required_test.go +++ b/cli/required_test.go @@ -119,7 +119,7 @@ func runTestCases(t *testing.T, testCases []testCase) { for _, tc := range testCases { cmd := newDummyCommand(tc.validateFunc) cmd.SetArgs(tc.args) - cmd.SetOutput(ioutil.Discard) + cmd.SetOut(ioutil.Discard) err := cmd.Execute() assert.ErrorContains(t, err, tc.expectedError) diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 23839c1046..35ccb130b7 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -59,7 +59,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand { setupHelpCommand(dockerCli, cmd, helpCmd) setHelpFunc(dockerCli, cmd) - cmd.SetOutput(dockerCli.Out()) + cmd.SetOut(dockerCli.Out()) commands.AddCommands(cmd, dockerCli) cli.DisableFlagsInUseLine(cmd)