Merge pull request #5781 from thaJeztah/less_pkg_errors
remove uses of pkg/errors in tests
This commit is contained in:
commit
4d7fe01d4b
@ -1,13 +1,13 @@
|
||||
package checkpoint
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -29,7 +29,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo", "bar"},
|
||||
checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error {
|
||||
return errors.Errorf("error creating checkpoint for container foo")
|
||||
return errors.New("error creating checkpoint for container foo")
|
||||
},
|
||||
expectedError: "error creating checkpoint for container foo",
|
||||
},
|
||||
|
@ -1,12 +1,12 @@
|
||||
package checkpoint
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -29,7 +29,7 @@ func TestCheckpointListErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
|
||||
return []checkpoint.Summary{}, errors.Errorf("error getting checkpoints for container foo")
|
||||
return []checkpoint.Summary{}, errors.New("error getting checkpoints for container foo")
|
||||
},
|
||||
expectedError: "error getting checkpoints for container foo",
|
||||
},
|
||||
|
@ -1,12 +1,12 @@
|
||||
package checkpoint
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -28,7 +28,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo", "bar"},
|
||||
checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error {
|
||||
return errors.Errorf("error deleting checkpoint")
|
||||
return errors.New("error deleting checkpoint")
|
||||
},
|
||||
expectedError: "error deleting checkpoint",
|
||||
},
|
||||
|
@ -3,6 +3,7 @@ package command
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@ -22,7 +23,6 @@ import (
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/fs"
|
||||
)
|
||||
|
@ -2,6 +2,8 @@ package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -12,7 +14,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -37,7 +38,7 @@ func TestConfigCreateErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"name", filepath.Join("testdata", configDataFile)},
|
||||
configCreateFunc: func(_ context.Context, configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
|
||||
return types.ConfigCreateResponse{}, errors.Errorf("error creating config")
|
||||
return types.ConfigCreateResponse{}, errors.New("error creating config")
|
||||
},
|
||||
expectedError: "error creating config",
|
||||
},
|
||||
@ -63,7 +64,7 @@ func TestConfigCreateWithName(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
|
||||
if spec.Name != name {
|
||||
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
}
|
||||
|
||||
actual = spec.Data
|
||||
@ -102,7 +103,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
|
||||
if !reflect.DeepEqual(spec, expected) {
|
||||
return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
|
||||
return types.ConfigCreateResponse{}, fmt.Errorf("expected %+v, got %+v", expected, spec)
|
||||
}
|
||||
|
||||
return types.ConfigCreateResponse{
|
||||
@ -128,11 +129,11 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
|
||||
if spec.Name != name {
|
||||
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
}
|
||||
|
||||
if spec.Templating.Name != expectedDriver.Name {
|
||||
return types.ConfigCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
return types.ConfigCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
}
|
||||
|
||||
return types.ConfigCreateResponse{
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -28,7 +28,7 @@ func TestConfigInspectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) {
|
||||
return swarm.Config{}, nil, errors.Errorf("error while inspecting the config")
|
||||
return swarm.Config{}, nil, errors.New("error while inspecting the config")
|
||||
},
|
||||
expectedError: "error while inspecting the config",
|
||||
},
|
||||
@ -45,7 +45,7 @@ func TestConfigInspectErrors(t *testing.T) {
|
||||
if configID == "foo" {
|
||||
return *builders.Config(builders.ConfigName("foo")), nil, nil
|
||||
}
|
||||
return swarm.Config{}, nil, errors.Errorf("error while inspecting the config")
|
||||
return swarm.Config{}, nil, errors.New("error while inspecting the config")
|
||||
},
|
||||
expectedError: "error while inspecting the config",
|
||||
},
|
||||
@ -77,7 +77,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
|
||||
args: []string{"foo"},
|
||||
configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
|
||||
if name != "foo" {
|
||||
return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
|
||||
return swarm.Config{}, nil, fmt.Errorf("invalid name, expected %s, got %s", "foo", name)
|
||||
}
|
||||
return *builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")), nil, nil
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
@ -11,7 +12,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -29,7 +29,7 @@ func TestConfigListErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
|
||||
return []swarm.Config{}, errors.Errorf("error listing configs")
|
||||
return []swarm.Config{}, errors.New("error listing configs")
|
||||
},
|
||||
expectedError: "error listing configs",
|
||||
},
|
||||
|
@ -1,12 +1,12 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -24,7 +24,7 @@ func TestConfigRemoveErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
configRemoveFunc: func(name string) error {
|
||||
return errors.Errorf("error removing config")
|
||||
return errors.New("error removing config")
|
||||
},
|
||||
expectedError: "error removing config",
|
||||
},
|
||||
@ -66,7 +66,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
|
||||
configRemoveFunc: func(name string) error {
|
||||
removedConfigs = append(removedConfigs, name)
|
||||
if name == "foo" {
|
||||
return errors.Errorf("error removing config: %s", name)
|
||||
return errors.New("error removing config: " + name)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -1,13 +1,13 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -23,7 +23,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
|
||||
args: []string{"5cb5bb5e4a3b"},
|
||||
expectedError: "something went wrong",
|
||||
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
|
||||
return container.InspectResponse{}, errors.Errorf("something went wrong")
|
||||
return container.InspectResponse{}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2,13 +2,13 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,13 +2,13 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/docker/cli/opts"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/fs"
|
||||
@ -259,7 +259,7 @@ func TestNewExecCommandErrors(t *testing.T) {
|
||||
args: []string{"5cb5bb5e4a3b", "-t", "-i", "bash"},
|
||||
expectedError: "something went wrong",
|
||||
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
|
||||
return container.InspectResponse{}, errors.Errorf("something went wrong")
|
||||
return container.InspectResponse{}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
networktypes "github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/pflag"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
@ -340,7 +340,7 @@ func compareRandomizedStrings(a, b, c, d string) error {
|
||||
if a == d && b == c {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("strings don't match")
|
||||
return errors.New("strings don't match")
|
||||
}
|
||||
|
||||
// Simple parse with MacAddress validation
|
||||
|
@ -2,13 +2,13 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func TestContainerPrunePromptTermination(t *testing.T) {
|
||||
|
@ -2,11 +2,11 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"sort"
|
||||
"sync"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,13 +2,13 @@ package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -16,7 +16,7 @@ import (
|
||||
func TestInitTtySizeErrors(t *testing.T) {
|
||||
expectedError := "failed to resize tty, using default size\n"
|
||||
fakeContainerExecResizeFunc := func(id string, options container.ResizeOptions) error {
|
||||
return errors.Errorf("Error response from daemon: no such exec")
|
||||
return errors.New("Error response from daemon: no such exec")
|
||||
}
|
||||
fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error {
|
||||
height, width := uint(1024), uint(768)
|
||||
|
@ -2,11 +2,11 @@ package idresolver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -14,7 +14,7 @@ import (
|
||||
func TestResolveError(t *testing.T) {
|
||||
cli := &fakeClient{
|
||||
nodeInspectFunc: func(nodeID string) (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting node")
|
||||
},
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ func TestResolveNode(t *testing.T) {
|
||||
{
|
||||
nodeID: "nodeID",
|
||||
nodeInspectFunc: func(string) (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting node")
|
||||
},
|
||||
expectedID: "nodeID",
|
||||
},
|
||||
@ -117,7 +117,7 @@ func TestResolveService(t *testing.T) {
|
||||
{
|
||||
serviceID: "serviceID",
|
||||
serviceInspectFunc: func(string) (swarm.Service, []byte, error) {
|
||||
return swarm.Service{}, []byte{}, errors.Errorf("error inspecting service")
|
||||
return swarm.Service{}, []byte{}, errors.New("error inspecting service")
|
||||
},
|
||||
expectedID: "serviceID",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -32,7 +32,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||
args: []string{"image:tag"},
|
||||
expectedError: "something went wrong",
|
||||
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) {
|
||||
return []image.HistoryResponseItem{{}}, errors.Errorf("something went wrong")
|
||||
return []image.HistoryResponseItem{{}}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1,13 +1,13 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -29,7 +29,7 @@ func TestNewImportCommandErrors(t *testing.T) {
|
||||
args: []string{"testdata/import-command-success.input.txt"},
|
||||
expectedError: "something went wrong",
|
||||
imageImportFunc: func(source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) {
|
||||
return nil, errors.Errorf("something went wrong")
|
||||
return nil, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/docker/cli/cli/config/configfile"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -30,7 +30,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
|
||||
name: "failed-list",
|
||||
expectedError: "something went wrong",
|
||||
imageListFunc: func(options image.ListOptions) ([]image.Summary, error) {
|
||||
return []image.Summary{}, errors.Errorf("something went wrong")
|
||||
return []image.Summary{}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -39,7 +39,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
|
||||
args: []string{},
|
||||
expectedError: "something went wrong",
|
||||
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) {
|
||||
return image.LoadResponse{}, errors.Errorf("something went wrong")
|
||||
return image.LoadResponse{}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@ -11,7 +12,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -34,7 +34,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
|
||||
args: []string{"--force"},
|
||||
expectedError: "something went wrong",
|
||||
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
|
||||
return image.PruneReport{}, errors.Errorf("something went wrong")
|
||||
return image.PruneReport{}, errors.New("something went wrong")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ func TestNewPushCommandErrors(t *testing.T) {
|
||||
args: []string{"image:repo"},
|
||||
expectedError: "Failed to push",
|
||||
imagePushFunc: func(ref string, options image.PushOptions) (io.ReadCloser, error) {
|
||||
return io.NopCloser(strings.NewReader("")), errors.Errorf("Failed to push")
|
||||
return io.NopCloser(strings.NewReader("")), errors.New("Failed to push")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -47,7 +47,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||
expectedError: "error removing image",
|
||||
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||
assert.Check(t, is.Equal("image1", img))
|
||||
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
||||
return []image.DeleteResponse{}, errors.New("error removing image")
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -57,7 +57,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
|
||||
assert.Check(t, !options.Force)
|
||||
assert.Check(t, options.PruneChildren)
|
||||
return []image.DeleteResponse{}, errors.Errorf("error removing image")
|
||||
return []image.DeleteResponse{}, errors.New("error removing image")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -39,7 +39,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
|
||||
isTerminal: false,
|
||||
expectedError: "error saving image",
|
||||
imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) {
|
||||
return io.NopCloser(strings.NewReader("")), errors.Errorf("error saving image")
|
||||
return io.NopCloser(strings.NewReader("")), errors.New("error saving image")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ package manifest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/cli/manifest/store"
|
||||
manifesttypes "github.com/docker/cli/cli/manifest/types"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -103,10 +103,10 @@ func TestManifestCreateNoManifest(t *testing.T) {
|
||||
cli.SetManifestStore(manifestStore)
|
||||
cli.SetRegistryClient(&fakeRegistryClient{
|
||||
getManifestFunc: func(_ context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) {
|
||||
return manifesttypes.ImageManifest{}, errors.Errorf("No such image: %v", ref)
|
||||
return manifesttypes.ImageManifest{}, errors.New("No such image: " + ref.String())
|
||||
},
|
||||
getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error) {
|
||||
return nil, errors.Errorf("No such manifest: %s", ref)
|
||||
return nil, errors.New("No such manifest: " + ref.String())
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -2,6 +2,7 @@ package manifest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -13,7 +14,6 @@ import (
|
||||
"github.com/docker/distribution/manifest/schema2"
|
||||
"github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -86,7 +86,7 @@ func TestInspectCommandNotFound(t *testing.T) {
|
||||
return types.ImageManifest{}, errors.New("missing")
|
||||
},
|
||||
getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]types.ImageManifest, error) {
|
||||
return nil, errors.Errorf("No such manifest: %s", ref)
|
||||
return nil, errors.New("No such manifest: " + ref.String())
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -2,6 +2,7 @@ package manifest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -9,17 +10,16 @@ import (
|
||||
"github.com/docker/cli/cli/manifest/store"
|
||||
manifesttypes "github.com/docker/cli/cli/manifest/types"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func newFakeRegistryClient() *fakeRegistryClient {
|
||||
return &fakeRegistryClient{
|
||||
getManifestFunc: func(_ context.Context, _ reference.Named) (manifesttypes.ImageManifest, error) {
|
||||
return manifesttypes.ImageManifest{}, errors.New("")
|
||||
return manifesttypes.ImageManifest{}, errors.New("unexpected error")
|
||||
},
|
||||
getManifestListFunc: func(_ context.Context, _ reference.Named) ([]manifesttypes.ImageManifest, error) {
|
||||
return nil, errors.Errorf("")
|
||||
return nil, errors.New("unexpected error")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -24,7 +24,7 @@ func TestNetworkConnectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"toto", "titi"},
|
||||
networkConnectFunc: func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
|
||||
return errors.Errorf("error connecting network")
|
||||
return errors.New("error connecting network")
|
||||
},
|
||||
expectedError: "error connecting network",
|
||||
},
|
||||
|
@ -2,13 +2,13 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -26,7 +26,7 @@ func TestNetworkCreateErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"toto"},
|
||||
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) {
|
||||
return network.CreateResponse{}, errors.Errorf("error creating network")
|
||||
return network.CreateResponse{}, errors.New("error creating network")
|
||||
},
|
||||
expectedError: "error creating network",
|
||||
},
|
||||
|
@ -2,11 +2,11 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -22,7 +22,7 @@ func TestNetworkDisconnectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"toto", "titi"},
|
||||
networkDisconnectFunc: func(ctx context.Context, networkID, container string, force bool) error {
|
||||
return errors.Errorf("error disconnecting network")
|
||||
return errors.New("error disconnecting network")
|
||||
},
|
||||
expectedError: "error disconnecting network",
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -23,7 +23,7 @@ func TestNetworkListErrors(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
|
||||
return []network.Summary{}, errors.Errorf("error creating network")
|
||||
return []network.Summary{}, errors.New("error creating network")
|
||||
},
|
||||
expectedError: "error creating network",
|
||||
},
|
||||
|
@ -2,13 +2,13 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func TestNetworkPrunePromptTermination(t *testing.T) {
|
||||
|
@ -2,13 +2,13 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -1,13 +1,13 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -24,14 +24,14 @@ func TestNodeDemoteErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
return errors.Errorf("error updating the node")
|
||||
return errors.New("error updating the node")
|
||||
},
|
||||
expectedError: "error updating the node",
|
||||
},
|
||||
@ -57,7 +57,7 @@ func TestNodeDemoteNoChange(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Role != swarm.NodeRoleWorker {
|
||||
return errors.Errorf("expected role worker, got %s", node.Role)
|
||||
return errors.New("expected role worker, got " + string(node.Role))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -74,7 +74,7 @@ func TestNodeDemoteMultipleNode(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Role != swarm.NodeRoleWorker {
|
||||
return errors.Errorf("expected role worker, got %s", node.Role)
|
||||
return errors.New("expected role worker, got " + string(node.Role))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -28,24 +28,24 @@ func TestNodeInspectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"self"},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
{
|
||||
args: []string{"self"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil
|
||||
@ -58,7 +58,7 @@ func TestNodeInspectErrors(t *testing.T) {
|
||||
"pretty": "true",
|
||||
},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -23,7 +23,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
nodeListFunc: func() ([]swarm.Node, error) {
|
||||
return []swarm.Node{}, errors.Errorf("error listing nodes")
|
||||
return []swarm.Node{}, errors.New("error listing nodes")
|
||||
},
|
||||
expectedError: "error listing nodes",
|
||||
},
|
||||
@ -36,7 +36,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
|
||||
}, nil
|
||||
},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
|
@ -1,13 +1,13 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -24,14 +24,14 @@ func TestNodePromoteErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
return errors.Errorf("error updating the node")
|
||||
return errors.New("error updating the node")
|
||||
},
|
||||
expectedError: "error updating the node",
|
||||
},
|
||||
@ -57,7 +57,7 @@ func TestNodePromoteNoChange(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Role != swarm.NodeRoleManager {
|
||||
return errors.Errorf("expected role manager, got %s", node.Role)
|
||||
return errors.New("expected role manager, got" + string(node.Role))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -74,7 +74,7 @@ func TestNodePromoteMultipleNode(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Role != swarm.NodeRoleManager {
|
||||
return errors.Errorf("expected role manager, got %s", node.Role)
|
||||
return errors.New("expected role manager, got" + string(node.Role))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -29,21 +29,21 @@ func TestNodePsErrors(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{}, errors.Errorf("error returning the task list")
|
||||
return []swarm.Task{}, errors.New("error returning the task list")
|
||||
},
|
||||
expectedError: "error returning the task list",
|
||||
},
|
||||
|
@ -1,11 +1,11 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -21,7 +21,7 @@ func TestNodeRemoveErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeRemoveFunc: func() error {
|
||||
return errors.Errorf("error removing the node")
|
||||
return errors.New("error removing the node")
|
||||
},
|
||||
expectedError: "error removing the node",
|
||||
},
|
||||
|
@ -1,13 +1,14 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -29,14 +30,14 @@ func TestNodeUpdateErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
return errors.Errorf("error updating the node")
|
||||
return errors.New("error updating the node")
|
||||
},
|
||||
expectedError: "error updating the node",
|
||||
},
|
||||
@ -86,7 +87,7 @@ func TestNodeUpdate(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Role != swarm.NodeRoleManager {
|
||||
return errors.Errorf("expected role manager, got %s", node.Role)
|
||||
return errors.New("expected role manager, got " + string(node.Role))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -101,7 +102,7 @@ func TestNodeUpdate(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if node.Availability != swarm.NodeAvailabilityDrain {
|
||||
return errors.Errorf("expected drain availability, got %s", node.Availability)
|
||||
return errors.New("expected drain availability, got " + string(node.Availability))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -116,7 +117,7 @@ func TestNodeUpdate(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if _, present := node.Annotations.Labels["lbl"]; !present {
|
||||
return errors.Errorf("expected 'lbl' label, got %v", node.Annotations.Labels)
|
||||
return fmt.Errorf("expected 'lbl' label, got %v", node.Annotations.Labels)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -131,7 +132,7 @@ func TestNodeUpdate(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if value, present := node.Annotations.Labels["key"]; !present || value != "value" {
|
||||
return errors.Errorf("expected 'key' label to be 'value', got %v", node.Annotations.Labels)
|
||||
return fmt.Errorf("expected 'key' label to be 'value', got %v", node.Annotations.Labels)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -148,7 +149,7 @@ func TestNodeUpdate(t *testing.T) {
|
||||
},
|
||||
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
|
||||
if len(node.Annotations.Labels) > 0 {
|
||||
return errors.Errorf("expected no labels, got %v", node.Annotations.Labels)
|
||||
return fmt.Errorf("expected no labels, got %v", node.Annotations.Labels)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -2,12 +2,12 @@ package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
|
||||
|
@ -2,6 +2,8 @@ package secret
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -12,7 +14,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -36,7 +37,7 @@ func TestSecretCreateErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"name", filepath.Join("testdata", secretDataFile)},
|
||||
secretCreateFunc: func(_ context.Context, secretSpec swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("error creating secret")
|
||||
return types.SecretCreateResponse{}, errors.New("error creating secret")
|
||||
},
|
||||
expectedError: "error creating secret",
|
||||
},
|
||||
@ -70,7 +71,7 @@ func TestSecretCreateWithName(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
||||
if !reflect.DeepEqual(spec, expected) {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected %+v, got %+v", expected, spec)
|
||||
}
|
||||
return types.SecretCreateResponse{
|
||||
ID: "ID-" + spec.Name,
|
||||
@ -93,11 +94,11 @@ func TestSecretCreateWithDriver(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
||||
if spec.Name != name {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
}
|
||||
|
||||
if spec.Driver.Name != expectedDriver.Name {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
}
|
||||
|
||||
return types.SecretCreateResponse{
|
||||
@ -108,7 +109,7 @@ func TestSecretCreateWithDriver(t *testing.T) {
|
||||
|
||||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name})
|
||||
cmd.Flags().Set("driver", expectedDriver.Name)
|
||||
assert.Check(t, cmd.Flags().Set("driver", expectedDriver.Name))
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
@ -117,16 +118,16 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
|
||||
expectedDriver := &swarm.Driver{
|
||||
Name: "template-driver",
|
||||
}
|
||||
name := "foo"
|
||||
const name = "foo"
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
||||
if spec.Name != name {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
}
|
||||
|
||||
if spec.Templating.Name != expectedDriver.Name {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
|
||||
}
|
||||
|
||||
return types.SecretCreateResponse{
|
||||
@ -137,7 +138,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
|
||||
|
||||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name})
|
||||
cmd.Flags().Set("template-driver", expectedDriver.Name)
|
||||
assert.Check(t, cmd.Flags().Set("template-driver", expectedDriver.Name))
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
@ -147,16 +148,16 @@ func TestSecretCreateWithLabels(t *testing.T) {
|
||||
"lbl1": "Label-foo",
|
||||
"lbl2": "Label-bar",
|
||||
}
|
||||
name := "foo"
|
||||
const name = "foo"
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
|
||||
if spec.Name != name {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(spec.Labels, expectedLabels) {
|
||||
return types.SecretCreateResponse{}, errors.Errorf("expected labels %v, got %v", expectedLabels, spec.Labels)
|
||||
return types.SecretCreateResponse{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, spec.Labels)
|
||||
}
|
||||
|
||||
return types.SecretCreateResponse{
|
||||
@ -167,8 +168,8 @@ func TestSecretCreateWithLabels(t *testing.T) {
|
||||
|
||||
cmd := newSecretCreateCommand(cli)
|
||||
cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
|
||||
cmd.Flags().Set("label", "lbl1=Label-foo")
|
||||
cmd.Flags().Set("label", "lbl2=Label-bar")
|
||||
assert.Check(t, cmd.Flags().Set("label", "lbl1=Label-foo"))
|
||||
assert.Check(t, cmd.Flags().Set("label", "lbl2=Label-bar"))
|
||||
assert.NilError(t, cmd.Execute())
|
||||
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package secret
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -28,7 +28,7 @@ func TestSecretInspectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
secretInspectFunc: func(_ context.Context, secretID string) (swarm.Secret, []byte, error) {
|
||||
return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret")
|
||||
return swarm.Secret{}, nil, errors.New("error while inspecting the secret")
|
||||
},
|
||||
expectedError: "error while inspecting the secret",
|
||||
},
|
||||
@ -45,7 +45,7 @@ func TestSecretInspectErrors(t *testing.T) {
|
||||
if secretID == "foo" {
|
||||
return *builders.Secret(builders.SecretName("foo")), nil, nil
|
||||
}
|
||||
return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret")
|
||||
return swarm.Secret{}, nil, errors.New("error while inspecting the secret")
|
||||
},
|
||||
expectedError: "error while inspecting the secret",
|
||||
},
|
||||
@ -77,7 +77,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
|
||||
args: []string{"foo"},
|
||||
secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) {
|
||||
if name != "foo" {
|
||||
return swarm.Secret{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
|
||||
return swarm.Secret{}, nil, fmt.Errorf("invalid name, expected %s, got %s", "foo", name)
|
||||
}
|
||||
return *builders.Secret(builders.SecretID("ID-foo"), builders.SecretName("foo")), nil, nil
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package secret
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
@ -11,7 +12,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -29,7 +29,7 @@ func TestSecretListErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
|
||||
return []swarm.Secret{}, errors.Errorf("error listing secrets")
|
||||
return []swarm.Secret{}, errors.New("error listing secrets")
|
||||
},
|
||||
expectedError: "error listing secrets",
|
||||
},
|
||||
|
@ -2,12 +2,12 @@ package secret
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -25,7 +25,7 @@ func TestSecretRemoveErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
secretRemoveFunc: func(_ context.Context, name string) error {
|
||||
return errors.Errorf("error removing secret")
|
||||
return errors.New("error removing secret")
|
||||
},
|
||||
expectedError: "error removing secret",
|
||||
},
|
||||
@ -67,7 +67,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
|
||||
secretRemoveFunc: func(_ context.Context, name string) error {
|
||||
removedSecrets = append(removedSecrets, name)
|
||||
if name == "foo" {
|
||||
return errors.Errorf("error removing secret: %s", name)
|
||||
return errors.New("error removing secret: " + name)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -34,7 +34,7 @@ func TestListErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{},
|
||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{}, errors.Errorf("error getting services")
|
||||
return []swarm.Service{}, errors.New("error getting services")
|
||||
},
|
||||
expectedError: "error getting services",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -33,7 +33,7 @@ func TestStackPsErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
||||
return nil, errors.Errorf("error getting tasks")
|
||||
return nil, errors.New("error getting tasks")
|
||||
},
|
||||
expectedError: "error getting tasks",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -27,7 +27,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return nil, errors.Errorf("error getting services")
|
||||
return nil, errors.New("error getting services")
|
||||
},
|
||||
expectedError: "error getting services",
|
||||
},
|
||||
@ -37,7 +37,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||
},
|
||||
nodeListFunc: func(options types.NodeListOptions) ([]swarm.Node, error) {
|
||||
return nil, errors.Errorf("error getting nodes")
|
||||
return nil, errors.New("error getting nodes")
|
||||
},
|
||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task()}, nil
|
||||
@ -50,7 +50,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||
},
|
||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
||||
return nil, errors.Errorf("error getting tasks")
|
||||
return nil, errors.New("error getting tasks")
|
||||
},
|
||||
expectedError: "error getting tasks",
|
||||
},
|
||||
|
@ -2,11 +2,11 @@ package swarm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test/network"
|
||||
networktypes "github.com/docker/docker/api/types/network"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -28,8 +28,8 @@ func TestValidateExternalNetworks(t *testing.T) {
|
||||
expectedMsg: "could not be found. You need to create a swarm-scoped network",
|
||||
},
|
||||
{
|
||||
inspectError: errors.New("Unexpected"),
|
||||
expectedMsg: "Unexpected",
|
||||
inspectError: errors.New("unexpected"),
|
||||
expectedMsg: "unexpected",
|
||||
},
|
||||
// FIXME(vdemeester) that doesn't work under windows, the check needs to be smarter
|
||||
/*
|
||||
@ -49,13 +49,13 @@ func TestValidateExternalNetworks(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
fakeClient := &network.FakeClient{
|
||||
client := &network.FakeClient{
|
||||
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) {
|
||||
return testcase.inspectResponse, testcase.inspectError
|
||||
},
|
||||
}
|
||||
networks := []string{testcase.network}
|
||||
err := validateExternalNetworks(context.Background(), fakeClient, networks)
|
||||
err := validateExternalNetworks(context.Background(), client, networks)
|
||||
if testcase.expectedMsg == "" {
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -26,28 +26,28 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
||||
{
|
||||
name: "init-failed",
|
||||
swarmInitFunc: func() (string, error) {
|
||||
return "", errors.Errorf("error initializing the swarm")
|
||||
return "", errors.New("error initializing the swarm")
|
||||
},
|
||||
expectedError: "error initializing the swarm",
|
||||
},
|
||||
{
|
||||
name: "init-failed-with-ip-choice",
|
||||
swarmInitFunc: func() (string, error) {
|
||||
return "", errors.Errorf("could not choose an IP address to advertise")
|
||||
return "", errors.New("could not choose an IP address to advertise")
|
||||
},
|
||||
expectedError: "could not choose an IP address to advertise - specify one with --advertise-addr",
|
||||
},
|
||||
{
|
||||
name: "swarm-inspect-after-init-failed",
|
||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
|
||||
return swarm.Swarm{}, errors.New("error inspecting the swarm")
|
||||
},
|
||||
expectedError: "error inspecting the swarm",
|
||||
},
|
||||
{
|
||||
name: "node-inspect-after-init-failed",
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting the node")
|
||||
},
|
||||
expectedError: "error inspecting the node",
|
||||
},
|
||||
@ -57,7 +57,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
||||
flagAutolock: "true",
|
||||
},
|
||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
||||
return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting swarm unlock key")
|
||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting swarm unlock key")
|
||||
},
|
||||
expectedError: "could not fetch unlock key: error getting swarm unlock key",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -34,7 +34,7 @@ func TestSwarmJoinErrors(t *testing.T) {
|
||||
name: "join-failed",
|
||||
args: []string{"remote"},
|
||||
swarmJoinFunc: func() error {
|
||||
return errors.Errorf("error joining the swarm")
|
||||
return errors.New("error joining the swarm")
|
||||
},
|
||||
expectedError: "error joining the swarm",
|
||||
},
|
||||
@ -42,7 +42,7 @@ func TestSwarmJoinErrors(t *testing.T) {
|
||||
name: "join-failed-on-init",
|
||||
args: []string{"remote"},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -43,7 +43,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||
name: "swarm-inspect-failed",
|
||||
args: []string{"worker"},
|
||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
|
||||
return swarm.Swarm{}, errors.New("error inspecting the swarm")
|
||||
},
|
||||
expectedError: "error inspecting the swarm",
|
||||
},
|
||||
@ -54,7 +54,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||
flagRotate: "true",
|
||||
},
|
||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
|
||||
return swarm.Swarm{}, errors.New("error inspecting the swarm")
|
||||
},
|
||||
expectedError: "error inspecting the swarm",
|
||||
},
|
||||
@ -65,7 +65,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||
flagRotate: "true",
|
||||
},
|
||||
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
return errors.Errorf("error updating the swarm")
|
||||
return errors.New("error updating the swarm")
|
||||
},
|
||||
expectedError: "error updating the swarm",
|
||||
},
|
||||
@ -73,7 +73,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||
name: "node-inspect-failed",
|
||||
args: []string{"worker"},
|
||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting node")
|
||||
return swarm.Node{}, []byte{}, errors.New("error inspecting node")
|
||||
},
|
||||
expectedError: "error inspecting node",
|
||||
},
|
||||
@ -81,7 +81,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
|
||||
name: "info-failed",
|
||||
args: []string{"worker"},
|
||||
infoFunc: func() (system.Info, error) {
|
||||
return system.Info{}, errors.Errorf("error asking for node info")
|
||||
return system.Info{}, errors.New("error asking for node info")
|
||||
},
|
||||
expectedError: "error asking for node info",
|
||||
},
|
||||
|
@ -1,12 +1,12 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -26,7 +26,7 @@ func TestSwarmLeaveErrors(t *testing.T) {
|
||||
{
|
||||
name: "leave-failed",
|
||||
swarmLeaveFunc: func() error {
|
||||
return errors.Errorf("error leaving the swarm")
|
||||
return errors.New("error leaving the swarm")
|
||||
},
|
||||
expectedError: "error leaving the swarm",
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -35,7 +35,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
||||
flagRotate: "true",
|
||||
},
|
||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
|
||||
return swarm.Swarm{}, errors.New("error inspecting the swarm")
|
||||
},
|
||||
expectedError: "error inspecting the swarm",
|
||||
},
|
||||
@ -58,14 +58,14 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
||||
return *builders.Swarm(builders.Autolock()), nil
|
||||
},
|
||||
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
return errors.Errorf("error updating the swarm")
|
||||
return errors.New("error updating the swarm")
|
||||
},
|
||||
expectedError: "error updating the swarm",
|
||||
},
|
||||
{
|
||||
name: "swarm-get-unlock-key-failed",
|
||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
||||
return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting unlock key")
|
||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key")
|
||||
},
|
||||
expectedError: "error getting unlock key",
|
||||
},
|
||||
@ -88,8 +88,8 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
||||
swarmGetUnlockKeyFunc: tc.swarmGetUnlockKeyFunc,
|
||||
}))
|
||||
cmd.SetArgs(tc.args)
|
||||
for key, value := range tc.flags {
|
||||
assert.Check(t, cmd.Flags().Set(key, value))
|
||||
for k, v := range tc.flags {
|
||||
assert.Check(t, cmd.Flags().Set(k, v))
|
||||
}
|
||||
cmd.SetOut(io.Discard)
|
||||
cmd.SetErr(io.Discard)
|
||||
@ -165,8 +165,8 @@ func TestSwarmUnlockKey(t *testing.T) {
|
||||
})
|
||||
cmd := newUnlockKeyCommand(cli)
|
||||
cmd.SetArgs(tc.args)
|
||||
for key, value := range tc.flags {
|
||||
assert.Check(t, cmd.Flags().Set(key, value))
|
||||
for k, v := range tc.flags {
|
||||
assert.Check(t, cmd.Flags().Set(k, v))
|
||||
}
|
||||
assert.NilError(t, cmd.Execute())
|
||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("unlockkeys-%s.golden", tc.name))
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -58,7 +58,7 @@ func TestSwarmUnlockErrors(t *testing.T) {
|
||||
}, nil
|
||||
},
|
||||
swarmUnlockFunc: func(req swarm.UnlockRequest) error {
|
||||
return errors.Errorf("error unlocking the swarm")
|
||||
return errors.New("error unlocking the swarm")
|
||||
},
|
||||
expectedError: "error unlocking the swarm",
|
||||
},
|
||||
@ -90,7 +90,7 @@ func TestSwarmUnlock(t *testing.T) {
|
||||
},
|
||||
swarmUnlockFunc: func(req swarm.UnlockRequest) error {
|
||||
if req.UnlockKey != input {
|
||||
return errors.Errorf("Invalid unlock key")
|
||||
return errors.New("invalid unlock key")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package swarm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -36,7 +36,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
||||
flagTaskHistoryLimit: "10",
|
||||
},
|
||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||
return swarm.Swarm{}, errors.Errorf("error inspecting the swarm")
|
||||
return swarm.Swarm{}, errors.New("error inspecting the swarm")
|
||||
},
|
||||
expectedError: "error inspecting the swarm",
|
||||
},
|
||||
@ -46,7 +46,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
||||
flagTaskHistoryLimit: "10",
|
||||
},
|
||||
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
return errors.Errorf("error updating the swarm")
|
||||
return errors.New("error updating the swarm")
|
||||
},
|
||||
expectedError: "error updating the swarm",
|
||||
},
|
||||
@ -59,7 +59,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
||||
return *builders.Swarm(), nil
|
||||
},
|
||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
||||
return types.SwarmUnlockKeyResponse{}, errors.Errorf("error getting unlock key")
|
||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key")
|
||||
},
|
||||
expectedError: "error getting unlock key",
|
||||
},
|
||||
@ -114,33 +114,33 @@ func TestSwarmUpdate(t *testing.T) {
|
||||
},
|
||||
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
|
||||
return errors.Errorf("historyLimit not correctly set")
|
||||
return errors.New("historyLimit not correctly set")
|
||||
}
|
||||
heartbeatDuration, err := time.ParseDuration("10s")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if swarm.Dispatcher.HeartbeatPeriod != heartbeatDuration {
|
||||
return errors.Errorf("heartbeatPeriodLimit not correctly set")
|
||||
return errors.New("heartbeatPeriodLimit not correctly set")
|
||||
}
|
||||
certExpiryDuration, err := time.ParseDuration("20s")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if swarm.CAConfig.NodeCertExpiry != certExpiryDuration {
|
||||
return errors.Errorf("certExpiry not correctly set")
|
||||
return errors.New("certExpiry not correctly set")
|
||||
}
|
||||
if len(swarm.CAConfig.ExternalCAs) != 1 || swarm.CAConfig.ExternalCAs[0].CACert != "trustroot" {
|
||||
return errors.Errorf("externalCA not correctly set")
|
||||
return errors.New("externalCA not correctly set")
|
||||
}
|
||||
if *swarm.Raft.KeepOldSnapshots != 10 {
|
||||
return errors.Errorf("keepOldSnapshots not correctly set")
|
||||
return errors.New("keepOldSnapshots not correctly set")
|
||||
}
|
||||
if swarm.Raft.SnapshotInterval != 100 {
|
||||
return errors.Errorf("snapshotInterval not correctly set")
|
||||
return errors.New("snapshotInterval not correctly set")
|
||||
}
|
||||
if !swarm.EncryptionConfig.AutoLockManagers {
|
||||
return errors.Errorf("autolock not correctly set")
|
||||
return errors.New("autolock not correctly set")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -153,7 +153,7 @@ func TestSwarmUpdate(t *testing.T) {
|
||||
},
|
||||
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
|
||||
return errors.Errorf("historyLimit not correctly set")
|
||||
return errors.New("historyLimit not correctly set")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@ -17,7 +18,6 @@ import (
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/streams"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"sort"
|
||||
@ -9,7 +11,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -34,7 +35,7 @@ func TestVolumeCreateErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) {
|
||||
return volume.Volume{}, errors.Errorf("error creating volume")
|
||||
return volume.Volume{}, errors.New("error creating volume")
|
||||
},
|
||||
expectedError: "error creating volume",
|
||||
},
|
||||
@ -60,7 +61,7 @@ func TestVolumeCreateWithName(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
||||
if body.Name != name {
|
||||
return volume.Volume{}, errors.Errorf("expected name %q, got %q", name, body.Name)
|
||||
return volume.Volume{}, fmt.Errorf("expected name %q, got %q", name, body.Name)
|
||||
}
|
||||
return volume.Volume{
|
||||
Name: body.Name,
|
||||
@ -99,16 +100,16 @@ func TestVolumeCreateWithFlags(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
|
||||
if body.Name != "" {
|
||||
return volume.Volume{}, errors.Errorf("expected empty name, got %q", body.Name)
|
||||
return volume.Volume{}, fmt.Errorf("expected empty name, got %q", body.Name)
|
||||
}
|
||||
if body.Driver != expectedDriver {
|
||||
return volume.Volume{}, errors.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
|
||||
return volume.Volume{}, fmt.Errorf("expected driver %q, got %q", expectedDriver, body.Driver)
|
||||
}
|
||||
if !reflect.DeepEqual(body.DriverOpts, expectedOpts) {
|
||||
return volume.Volume{}, errors.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
|
||||
return volume.Volume{}, fmt.Errorf("expected drivers opts %v, got %v", expectedOpts, body.DriverOpts)
|
||||
}
|
||||
if !reflect.DeepEqual(body.Labels, expectedLabels) {
|
||||
return volume.Volume{}, errors.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
|
||||
return volume.Volume{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, body.Labels)
|
||||
}
|
||||
return volume.Volume{
|
||||
Name: name,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -27,7 +27,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"foo"},
|
||||
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
||||
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
|
||||
return volume.Volume{}, errors.New("error while inspecting the volume")
|
||||
},
|
||||
expectedError: "error while inspecting the volume",
|
||||
},
|
||||
@ -46,7 +46,7 @@ func TestVolumeInspectErrors(t *testing.T) {
|
||||
Name: "foo",
|
||||
}, nil
|
||||
}
|
||||
return volume.Volume{}, errors.Errorf("error while inspecting the volume")
|
||||
return volume.Volume{}, errors.New("error while inspecting the volume")
|
||||
},
|
||||
expectedError: "error while inspecting the volume",
|
||||
},
|
||||
@ -78,7 +78,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
|
||||
args: []string{"foo"},
|
||||
volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
|
||||
if volumeID != "foo" {
|
||||
return volume.Volume{}, errors.Errorf("Invalid volumeID, expected %s, got %s", "foo", volumeID)
|
||||
return volume.Volume{}, fmt.Errorf("invalid volumeID, expected %s, got %s", "foo", volumeID)
|
||||
}
|
||||
return *builders.Volume(), nil
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -27,7 +27,7 @@ func TestVolumeListErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
|
||||
return volume.ListResponse{}, errors.Errorf("error listing volumes")
|
||||
return volume.ListResponse{}, errors.New("error listing volumes")
|
||||
},
|
||||
expectedError: "error listing volumes",
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package volume
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -38,7 +38,7 @@ func TestVolumePruneErrors(t *testing.T) {
|
||||
"force": "true",
|
||||
},
|
||||
volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) {
|
||||
return volume.PruneReport{}, errors.Errorf("error pruning volumes")
|
||||
return volume.PruneReport{}, errors.New("error pruning volumes")
|
||||
},
|
||||
expectedError: "error pruning volumes",
|
||||
},
|
||||
|
@ -1,11 +1,11 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -21,7 +21,7 @@ func TestVolumeRemoveErrors(t *testing.T) {
|
||||
{
|
||||
args: []string{"nodeID"},
|
||||
volumeRemoveFunc: func(volumeID string, force bool) error {
|
||||
return errors.Errorf("error removing the volume")
|
||||
return errors.New("error removing the volume")
|
||||
},
|
||||
expectedError: "error removing the volume",
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ package convert
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -12,7 +13,6 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package credentials
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@ -10,7 +11,6 @@ import (
|
||||
"github.com/docker/cli/cli/config/types"
|
||||
"github.com/docker/docker-credential-helpers/client"
|
||||
"github.com/docker/docker-credential-helpers/credentials"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -22,7 +22,7 @@ const (
|
||||
missingCredsAddress = "https://missing.docker.io/v1"
|
||||
)
|
||||
|
||||
var errCommandExited = errors.Errorf("exited 1")
|
||||
var errCommandExited = errors.New("exited 1")
|
||||
|
||||
// mockCommand simulates interactions between the docker client and a remote
|
||||
// credentials helper.
|
||||
|
@ -13,7 +13,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/fs"
|
||||
"gotest.tools/v3/icmd"
|
||||
@ -87,7 +86,7 @@ func buildPlugin(t *testing.T, ctx context.Context) (string, error) {
|
||||
cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
|
||||
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return "", errors.Wrapf(err, "error building basic plugin bin: %s", string(out))
|
||||
return "", fmt.Errorf("error building basic plugin bin: %s: %w", string(out), err)
|
||||
}
|
||||
|
||||
return installPath, nil
|
||||
|
@ -1,6 +1,7 @@
|
||||
package environment
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/icmd"
|
||||
"gotest.tools/v3/poll"
|
||||
"gotest.tools/v3/skip"
|
||||
|
@ -1,10 +1,9 @@
|
||||
package output
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Assert checks output lines at specified locations
|
||||
@ -30,7 +29,7 @@ func Prefix(expected string) func(string) error {
|
||||
if strings.HasPrefix(actual, expected) {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("expected %q to start with %q", actual, expected)
|
||||
return fmt.Errorf("expected %q to start with %q", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +39,7 @@ func Suffix(expected string) func(string) error {
|
||||
if strings.HasSuffix(actual, expected) {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("expected %q to end with %q", actual, expected)
|
||||
return fmt.Errorf("expected %q to end with %q", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +49,7 @@ func Contains(expected string) func(string) error {
|
||||
if strings.Contains(actual, expected) {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("expected %q to contain %q", actual, expected)
|
||||
return fmt.Errorf("expected %q to contain %q", actual, expected)
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,6 +59,6 @@ func Equals(expected string) func(string) error {
|
||||
if expected == actual {
|
||||
return nil
|
||||
}
|
||||
return errors.Errorf("got %q, expected %q", actual, expected)
|
||||
return fmt.Errorf("got %q, expected %q", actual, expected)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user