From d06eafc516387fc2bd4a3bda6ada6c0455e05e7a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 25 Feb 2022 14:29:10 +0100 Subject: [PATCH] cli/command/plugin: remove deprecated io/ioutil Signed-off-by: Sebastiaan van Stijn (cherry picked from commit f61aab59f75f250a1c9b1846217c0bc8fffc5cfa) Signed-off-by: Cory Snider --- cli/command/plugin/create_test.go | 11 +++++------ cli/command/plugin/disable_test.go | 4 ++-- cli/command/plugin/enable_test.go | 4 ++-- cli/command/plugin/inspect_test.go | 4 ++-- cli/command/plugin/install_test.go | 9 ++++----- cli/command/plugin/list_test.go | 4 ++-- cli/command/plugin/remove_test.go | 4 ++-- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/cli/command/plugin/create_test.go b/cli/command/plugin/create_test.go index 923f931beb..37ce5e22c4 100644 --- a/cli/command/plugin/create_test.go +++ b/cli/command/plugin/create_test.go @@ -3,7 +3,6 @@ package plugin import ( "fmt" "io" - "io/ioutil" "runtime" "testing" @@ -41,7 +40,7 @@ func TestCreateErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -53,7 +52,7 @@ func TestCreateErrorOnFileAsContextDir(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpFile.Path()}) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), "context must be a directory") } @@ -64,7 +63,7 @@ func TestCreateErrorOnContextDirWithoutConfig(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) expectedErr := "config.json: no such file or directory" if runtime.GOOS == "windows" { @@ -82,7 +81,7 @@ func TestCreateErrorOnInvalidConfig(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), "invalid") } @@ -100,7 +99,7 @@ func TestCreateErrorFromDaemon(t *testing.T) { cmd := newCreateCommand(cli) cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()}) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.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 bd1f812339..ca2e0d2cbb 100644 --- a/cli/command/plugin/disable_test.go +++ b/cli/command/plugin/disable_test.go @@ -2,7 +2,7 @@ package plugin import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -40,7 +40,7 @@ func TestPluginDisableErrors(t *testing.T) { pluginDisableFunc: tc.pluginDisableFunc, })) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.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 5652543b70..1d8840e77c 100644 --- a/cli/command/plugin/enable_test.go +++ b/cli/command/plugin/enable_test.go @@ -2,7 +2,7 @@ package plugin import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -51,7 +51,7 @@ func TestPluginEnableErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.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 66454b462f..4d3127660a 100644 --- a/cli/command/plugin/inspect_test.go +++ b/cli/command/plugin/inspect_test.go @@ -2,7 +2,7 @@ package plugin import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -73,7 +73,7 @@ func TestInspectErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.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 1e6486a013..f1a4ff975b 100644 --- a/cli/command/plugin/install_test.go +++ b/cli/command/plugin/install_test.go @@ -3,7 +3,6 @@ package plugin import ( "fmt" "io" - "io/ioutil" "strings" "testing" @@ -58,7 +57,7 @@ func TestInstallErrors(t *testing.T) { cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc}) cmd := newInstallCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -100,7 +99,7 @@ func TestInstallContentTrustErrors(t *testing.T) { cli.SetNotaryClient(tc.notaryFunc) cmd := newInstallCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } } @@ -117,7 +116,7 @@ func TestInstall(t *testing.T) { args: []string{"foo"}, expectedOutput: "Installed plugin foo\n", installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader("")), nil + return io.NopCloser(strings.NewReader("")), nil }, }, { @@ -126,7 +125,7 @@ func TestInstall(t *testing.T) { expectedOutput: "Installed plugin foo\n", installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) { assert.Check(t, options.Disabled) - return ioutil.NopCloser(strings.NewReader("")), nil + return io.NopCloser(strings.NewReader("")), nil }, }, } diff --git a/cli/command/plugin/list_test.go b/cli/command/plugin/list_test.go index b51565969b..ed30eb1c59 100644 --- a/cli/command/plugin/list_test.go +++ b/cli/command/plugin/list_test.go @@ -2,7 +2,7 @@ package plugin import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -52,7 +52,7 @@ func TestListErrors(t *testing.T) { for key, value := range tc.flags { cmd.Flags().Set(key, value) } - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.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 f436c5accd..1b811f0c70 100644 --- a/cli/command/plugin/remove_test.go +++ b/cli/command/plugin/remove_test.go @@ -2,7 +2,7 @@ package plugin import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -37,7 +37,7 @@ func TestRemoveErrors(t *testing.T) { }) cmd := newRemoveCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) assert.ErrorContains(t, cmd.Execute(), tc.expectedError) } }