cli/command/plugin: remove deprecated io/ioutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9bdeb09ae9
commit
f61aab59f7
@ -3,7 +3,6 @@ package plugin
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ func TestCreateErrors(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ func TestCreateErrorOnFileAsContextDir(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpFile.Path()})
|
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")
|
assert.ErrorContains(t, cmd.Execute(), "context must be a directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ func TestCreateErrorOnContextDirWithoutConfig(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
expectedErr := "config.json: no such file or directory"
|
expectedErr := "config.json: no such file or directory"
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
@ -82,7 +81,7 @@ func TestCreateErrorOnInvalidConfig(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{})
|
cli := test.NewFakeCli(&fakeClient{})
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "invalid")
|
assert.ErrorContains(t, cmd.Execute(), "invalid")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ func TestCreateErrorFromDaemon(t *testing.T) {
|
|||||||
|
|
||||||
cmd := newCreateCommand(cli)
|
cmd := newCreateCommand(cli)
|
||||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), "Error creating plugin")
|
assert.ErrorContains(t, cmd.Execute(), "Error creating plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
@ -40,7 +40,7 @@ func TestPluginDisableErrors(t *testing.T) {
|
|||||||
pluginDisableFunc: tc.pluginDisableFunc,
|
pluginDisableFunc: tc.pluginDisableFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
@ -51,7 +51,7 @@ func TestPluginEnableErrors(t *testing.T) {
|
|||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
@ -73,7 +73,7 @@ func TestInspectErrors(t *testing.T) {
|
|||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package plugin
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ func TestInstallErrors(t *testing.T) {
|
|||||||
cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc})
|
cli := test.NewFakeCli(&fakeClient{pluginInstallFunc: tc.installFunc})
|
||||||
cmd := newInstallCommand(cli)
|
cmd := newInstallCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +99,7 @@ func TestInstallContentTrustErrors(t *testing.T) {
|
|||||||
cli.SetNotaryClient(tc.notaryFunc)
|
cli.SetNotaryClient(tc.notaryFunc)
|
||||||
cmd := newInstallCommand(cli)
|
cmd := newInstallCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +116,7 @@ func TestInstall(t *testing.T) {
|
|||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
expectedOutput: "Installed plugin foo\n",
|
expectedOutput: "Installed plugin foo\n",
|
||||||
installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
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",
|
expectedOutput: "Installed plugin foo\n",
|
||||||
installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
||||||
assert.Check(t, options.Disabled)
|
assert.Check(t, options.Disabled)
|
||||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
return io.NopCloser(strings.NewReader("")), nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
@ -52,7 +52,7 @@ func TestListErrors(t *testing.T) {
|
|||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package plugin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
@ -37,7 +37,7 @@ func TestRemoveErrors(t *testing.T) {
|
|||||||
})
|
})
|
||||||
cmd := newRemoveCommand(cli)
|
cmd := newRemoveCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user