cli/command/plugin: remove deprecated io/ioutil

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-25 14:29:10 +01:00
parent 9bdeb09ae9
commit f61aab59f7
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
7 changed files with 19 additions and 21 deletions

View File

@ -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")
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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)
})
}

View File

@ -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
},
},
}

View File

@ -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)
}
}

View File

@ -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)
}
}