mirror of https://github.com/docker/cli.git
cli/command/stack: remove deprecated io/ioutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
d1f26de646
commit
d59330f40d
|
@ -1,7 +1,7 @@
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
|
@ -11,7 +11,7 @@ import (
|
||||||
func TestDeployWithEmptyName(t *testing.T) {
|
func TestDeployWithEmptyName(t *testing.T) {
|
||||||
cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs([]string{"' '"})
|
cmd.SetArgs([]string{"' '"})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
|
@ -49,7 +49,7 @@ func TestListErrors(t *testing.T) {
|
||||||
serviceListFunc: tc.serviceListFunc,
|
serviceListFunc: tc.serviceListFunc,
|
||||||
}))
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetArgs(tc.args)
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
for key, value := range tc.flags {
|
for key, value := range tc.flags {
|
||||||
cmd.Flags().Set(key, value)
|
cmd.Flags().Set(key, value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package loader
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -132,9 +131,9 @@ func loadConfigFile(filename string, stdin io.Reader) (*composetypes.ConfigFile,
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if filename == "-" {
|
if filename == "-" {
|
||||||
bytes, err = ioutil.ReadAll(stdin)
|
bytes, err = io.ReadAll(stdin)
|
||||||
} else {
|
} else {
|
||||||
bytes, err = ioutil.ReadFile(filename)
|
bytes, err = os.ReadFile(filename)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ func TestStackPsErrors(t *testing.T) {
|
||||||
taskListFunc: tc.taskListFunc,
|
taskListFunc: tc.taskListFunc,
|
||||||
}))
|
}))
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ func TestStackPs(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)
|
||||||
|
|
||||||
if tc.expectedErr != "" {
|
if tc.expectedErr != "" {
|
||||||
assert.Error(t, cmd.Execute(), tc.expectedErr)
|
assert.Error(t, cmd.Execute(), tc.expectedErr)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ func fakeClientForRemoveStackTest(version string) *fakeClient {
|
||||||
func TestRemoveWithEmptyName(t *testing.T) {
|
func TestRemoveWithEmptyName(t *testing.T) {
|
||||||
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs([]string{"good", "' '", "alsogood"})
|
cmd.SetArgs([]string{"good", "' '", "alsogood"})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ func TestRemoveContinueAfterError(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmd := newRemoveCommand(test.NewFakeCli(cli))
|
cmd := newRemoveCommand(test.NewFakeCli(cli))
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
cmd.SetArgs([]string{"foo", "bar"})
|
cmd.SetArgs([]string{"foo", "bar"})
|
||||||
|
|
||||||
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package stack
|
package stack
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
|
@ -79,7 +79,7 @@ func TestStackServicesErrors(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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||||
func TestRunServicesWithEmptyName(t *testing.T) {
|
func TestRunServicesWithEmptyName(t *testing.T) {
|
||||||
cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}))
|
cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}))
|
||||||
cmd.SetArgs([]string{"' '"})
|
cmd.SetArgs([]string{"' '"})
|
||||||
cmd.SetOut(ioutil.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
||||||
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue