Merge pull request #5781 from thaJeztah/less_pkg_errors

remove uses of pkg/errors in tests
This commit is contained in:
Sebastiaan van Stijn 2025-02-03 10:56:31 +01:00 committed by GitHub
commit 4d7fe01d4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
71 changed files with 219 additions and 217 deletions

View File

@ -1,13 +1,13 @@
package checkpoint package checkpoint
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/checkpoint" "github.com/docker/docker/api/types/checkpoint"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -29,7 +29,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error { 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", expectedError: "error creating checkpoint for container foo",
}, },

View File

@ -1,12 +1,12 @@
package checkpoint package checkpoint
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/checkpoint" "github.com/docker/docker/api/types/checkpoint"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -29,7 +29,7 @@ func TestCheckpointListErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) { 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", expectedError: "error getting checkpoints for container foo",
}, },

View File

@ -1,12 +1,12 @@
package checkpoint package checkpoint
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/checkpoint" "github.com/docker/docker/api/types/checkpoint"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -28,7 +28,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error { checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error {
return errors.Errorf("error deleting checkpoint") return errors.New("error deleting checkpoint")
}, },
expectedError: "error deleting checkpoint", expectedError: "error deleting checkpoint",
}, },

View File

@ -3,6 +3,7 @@ package command
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"net" "net"
@ -22,7 +23,6 @@ import (
"github.com/docker/docker/api" "github.com/docker/docker/api"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/fs" "gotest.tools/v3/fs"
) )

View File

@ -2,6 +2,8 @@ package config
import ( import (
"context" "context"
"errors"
"fmt"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
@ -12,7 +14,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -37,7 +38,7 @@ func TestConfigCreateErrors(t *testing.T) {
{ {
args: []string{"name", filepath.Join("testdata", configDataFile)}, args: []string{"name", filepath.Join("testdata", configDataFile)},
configCreateFunc: func(_ context.Context, configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { 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", expectedError: "error creating config",
}, },
@ -63,7 +64,7 @@ func TestConfigCreateWithName(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if spec.Name != name { 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 actual = spec.Data
@ -102,7 +103,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if !reflect.DeepEqual(spec, expected) { 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{ return types.ConfigCreateResponse{
@ -128,11 +129,11 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if spec.Name != name { 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 { 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{ return types.ConfigCreateResponse{

View File

@ -2,6 +2,7 @@ package config
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -28,7 +28,7 @@ func TestConfigInspectErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) { 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", expectedError: "error while inspecting the config",
}, },
@ -45,7 +45,7 @@ func TestConfigInspectErrors(t *testing.T) {
if configID == "foo" { if configID == "foo" {
return *builders.Config(builders.ConfigName("foo")), nil, nil 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", expectedError: "error while inspecting the config",
}, },
@ -77,7 +77,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
args: []string{"foo"}, args: []string{"foo"},
configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
if name != "foo" { 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 return *builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")), nil, nil
}, },

View File

@ -2,6 +2,7 @@ package config
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"time" "time"
@ -11,7 +12,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -29,7 +29,7 @@ func TestConfigListErrors(t *testing.T) {
}, },
{ {
configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { 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", expectedError: "error listing configs",
}, },

View File

@ -1,12 +1,12 @@
package config package config
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -24,7 +24,7 @@ func TestConfigRemoveErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
configRemoveFunc: func(name string) error { configRemoveFunc: func(name string) error {
return errors.Errorf("error removing config") return errors.New("error removing config")
}, },
expectedError: "error removing config", expectedError: "error removing config",
}, },
@ -66,7 +66,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
configRemoveFunc: func(name string) error { configRemoveFunc: func(name string) error {
removedConfigs = append(removedConfigs, name) removedConfigs = append(removedConfigs, name)
if name == "foo" { if name == "foo" {
return errors.Errorf("error removing config: %s", name) return errors.New("error removing config: " + name)
} }
return nil return nil
}, },

View File

@ -1,13 +1,13 @@
package container package container
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -23,7 +23,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
args: []string{"5cb5bb5e4a3b"}, args: []string{"5cb5bb5e4a3b"},
expectedError: "something went wrong", expectedError: "something went wrong",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) { containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{}, errors.Errorf("something went wrong") return container.InspectResponse{}, errors.New("something went wrong")
}, },
}, },
{ {

View File

@ -2,13 +2,13 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,13 +2,13 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,6 +2,7 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"os" "os"
"testing" "testing"
@ -12,7 +13,6 @@ import (
"github.com/docker/cli/opts" "github.com/docker/cli/opts"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/fs" "gotest.tools/v3/fs"
@ -259,7 +259,7 @@ func TestNewExecCommandErrors(t *testing.T) {
args: []string{"5cb5bb5e4a3b", "-t", "-i", "bash"}, args: []string{"5cb5bb5e4a3b", "-t", "-i", "bash"},
expectedError: "something went wrong", expectedError: "something went wrong",
containerInspectFunc: func(containerID string) (container.InspectResponse, error) { containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
return container.InspectResponse{}, errors.Errorf("something went wrong") return container.InspectResponse{}, errors.New("something went wrong")
}, },
}, },
} }

View File

@ -1,6 +1,7 @@
package container package container
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -12,7 +13,6 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
networktypes "github.com/docker/docker/api/types/network" networktypes "github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
"github.com/pkg/errors"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -340,7 +340,7 @@ func compareRandomizedStrings(a, b, c, d string) error {
if a == d && b == c { if a == d && b == c {
return nil return nil
} }
return errors.Errorf("strings don't match") return errors.New("strings don't match")
} }
// Simple parse with MacAddress validation // Simple parse with MacAddress validation

View File

@ -2,13 +2,13 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/pkg/errors"
) )
func TestContainerPrunePromptTermination(t *testing.T) { func TestContainerPrunePromptTermination(t *testing.T) {

View File

@ -2,11 +2,11 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,6 +2,7 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"sort" "sort"
"sync" "sync"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,6 +2,7 @@ package container
import ( import (
"context" "context"
"errors"
"io" "io"
"sort" "sort"
"sync" "sync"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,13 +2,13 @@ package container
import ( import (
"context" "context"
"errors"
"testing" "testing"
"time" "time"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -16,7 +16,7 @@ import (
func TestInitTtySizeErrors(t *testing.T) { func TestInitTtySizeErrors(t *testing.T) {
expectedError := "failed to resize tty, using default size\n" expectedError := "failed to resize tty, using default size\n"
fakeContainerExecResizeFunc := func(id string, options container.ResizeOptions) error { 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 { fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error {
height, width := uint(1024), uint(768) height, width := uint(1024), uint(768)

View File

@ -2,11 +2,11 @@ package idresolver
import ( import (
"context" "context"
"errors"
"testing" "testing"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -14,7 +14,7 @@ import (
func TestResolveError(t *testing.T) { func TestResolveError(t *testing.T) {
cli := &fakeClient{ cli := &fakeClient{
nodeInspectFunc: func(nodeID string) (swarm.Node, []byte, error) { 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", nodeID: "nodeID",
nodeInspectFunc: func(string) (swarm.Node, []byte, error) { 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", expectedID: "nodeID",
}, },
@ -117,7 +117,7 @@ func TestResolveService(t *testing.T) {
{ {
serviceID: "serviceID", serviceID: "serviceID",
serviceInspectFunc: func(string) (swarm.Service, []byte, error) { 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", expectedID: "serviceID",
}, },

View File

@ -1,6 +1,7 @@
package image package image
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -32,7 +32,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
args: []string{"image:tag"}, args: []string{"image:tag"},
expectedError: "something went wrong", expectedError: "something went wrong",
imageHistoryFunc: func(img string, options image.HistoryOptions) ([]image.HistoryResponseItem, error) { 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")
}, },
}, },
{ {

View File

@ -1,13 +1,13 @@
package image package image
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -29,7 +29,7 @@ func TestNewImportCommandErrors(t *testing.T) {
args: []string{"testdata/import-command-success.input.txt"}, args: []string{"testdata/import-command-success.input.txt"},
expectedError: "something went wrong", expectedError: "something went wrong",
imageImportFunc: func(source image.ImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error) { 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")
}, },
}, },
} }

View File

@ -1,6 +1,7 @@
package image package image
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -8,7 +9,6 @@ import (
"github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -30,7 +30,7 @@ func TestNewImagesCommandErrors(t *testing.T) {
name: "failed-list", name: "failed-list",
expectedError: "something went wrong", expectedError: "something went wrong",
imageListFunc: func(options image.ListOptions) ([]image.Summary, error) { imageListFunc: func(options image.ListOptions) ([]image.Summary, error) {
return []image.Summary{}, errors.Errorf("something went wrong") return []image.Summary{}, errors.New("something went wrong")
}, },
}, },
} }

View File

@ -1,6 +1,7 @@
package image package image
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -39,7 +39,7 @@ func TestNewLoadCommandErrors(t *testing.T) {
args: []string{}, args: []string{},
expectedError: "something went wrong", expectedError: "something went wrong",
imageLoadFunc: func(input io.Reader, options image.LoadOptions) (image.LoadResponse, error) { 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")
}, },
}, },
{ {

View File

@ -2,6 +2,7 @@ package image
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -11,7 +12,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -34,7 +34,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
args: []string{"--force"}, args: []string{"--force"},
expectedError: "something went wrong", expectedError: "something went wrong",
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) { imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
return image.PruneReport{}, errors.Errorf("something went wrong") return image.PruneReport{}, errors.New("something went wrong")
}, },
}, },
} }

View File

@ -1,13 +1,13 @@
package image package image
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -33,7 +33,7 @@ func TestNewPushCommandErrors(t *testing.T) {
args: []string{"image:repo"}, args: []string{"image:repo"},
expectedError: "Failed to push", expectedError: "Failed to push",
imagePushFunc: func(ref string, options image.PushOptions) (io.ReadCloser, error) { 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")
}, },
}, },
} }

View File

@ -1,13 +1,13 @@
package image package image
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -47,7 +47,7 @@ func TestNewRemoveCommandErrors(t *testing.T) {
expectedError: "error removing image", expectedError: "error removing image",
imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) { imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
assert.Check(t, is.Equal("image1", img)) 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) { imageRemoveFunc: func(img string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
assert.Check(t, !options.Force) assert.Check(t, !options.Force)
assert.Check(t, options.PruneChildren) assert.Check(t, options.PruneChildren)
return []image.DeleteResponse{}, errors.Errorf("error removing image") return []image.DeleteResponse{}, errors.New("error removing image")
}, },
}, },
} }

View File

@ -1,6 +1,7 @@
package image package image
import ( import (
"errors"
"io" "io"
"os" "os"
"strings" "strings"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -39,7 +39,7 @@ func TestNewSaveCommandErrors(t *testing.T) {
isTerminal: false, isTerminal: false,
expectedError: "error saving image", expectedError: "error saving image",
imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) { 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")
}, },
}, },
{ {

View File

@ -2,6 +2,7 @@ package manifest
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/cli/manifest/store" "github.com/docker/cli/cli/manifest/store"
manifesttypes "github.com/docker/cli/cli/manifest/types" manifesttypes "github.com/docker/cli/cli/manifest/types"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -103,10 +103,10 @@ func TestManifestCreateNoManifest(t *testing.T) {
cli.SetManifestStore(manifestStore) cli.SetManifestStore(manifestStore)
cli.SetRegistryClient(&fakeRegistryClient{ cli.SetRegistryClient(&fakeRegistryClient{
getManifestFunc: func(_ context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) { 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) { 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())
}, },
}) })

View File

@ -2,6 +2,7 @@ package manifest
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
@ -13,7 +14,6 @@ import (
"github.com/docker/distribution/manifest/schema2" "github.com/docker/distribution/manifest/schema2"
"github.com/opencontainers/go-digest" "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -86,7 +86,7 @@ func TestInspectCommandNotFound(t *testing.T) {
return types.ImageManifest{}, errors.New("missing") return types.ImageManifest{}, errors.New("missing")
}, },
getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]types.ImageManifest, error) { 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())
}, },
}) })

View File

@ -2,6 +2,7 @@ package manifest
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
@ -9,17 +10,16 @@ import (
"github.com/docker/cli/cli/manifest/store" "github.com/docker/cli/cli/manifest/store"
manifesttypes "github.com/docker/cli/cli/manifest/types" manifesttypes "github.com/docker/cli/cli/manifest/types"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
func newFakeRegistryClient() *fakeRegistryClient { func newFakeRegistryClient() *fakeRegistryClient {
return &fakeRegistryClient{ return &fakeRegistryClient{
getManifestFunc: func(_ context.Context, _ reference.Named) (manifesttypes.ImageManifest, error) { 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) { getManifestListFunc: func(_ context.Context, _ reference.Named) ([]manifesttypes.ImageManifest, error) {
return nil, errors.Errorf("") return nil, errors.New("unexpected error")
}, },
} }
} }

View File

@ -2,12 +2,12 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -24,7 +24,7 @@ func TestNetworkConnectErrors(t *testing.T) {
{ {
args: []string{"toto", "titi"}, args: []string{"toto", "titi"},
networkConnectFunc: func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { 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", expectedError: "error connecting network",
}, },

View File

@ -2,13 +2,13 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -26,7 +26,7 @@ func TestNetworkCreateErrors(t *testing.T) {
{ {
args: []string{"toto"}, args: []string{"toto"},
networkCreateFunc: func(ctx context.Context, name string, createBody network.CreateOptions) (network.CreateResponse, error) { 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", expectedError: "error creating network",
}, },

View File

@ -2,11 +2,11 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -22,7 +22,7 @@ func TestNetworkDisconnectErrors(t *testing.T) {
{ {
args: []string{"toto", "titi"}, args: []string{"toto", "titi"},
networkDisconnectFunc: func(ctx context.Context, networkID, container string, force bool) error { 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", expectedError: "error disconnecting network",
}, },

View File

@ -2,6 +2,7 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
@ -10,7 +11,6 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -23,7 +23,7 @@ func TestNetworkListErrors(t *testing.T) {
}{ }{
{ {
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) { 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", expectedError: "error creating network",
}, },

View File

@ -2,13 +2,13 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
) )
func TestNetworkPrunePromptTermination(t *testing.T) { func TestNetworkPrunePromptTermination(t *testing.T) {

View File

@ -2,13 +2,13 @@ package network
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -1,13 +1,13 @@
package node package node
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -24,14 +24,14 @@ func TestNodeDemoteErrors(t *testing.T) {
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting the node",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { 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", 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 { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Role != swarm.NodeRoleWorker { 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 return nil
}, },
@ -74,7 +74,7 @@ func TestNodeDemoteMultipleNode(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Role != swarm.NodeRoleWorker { 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 return nil
}, },

View File

@ -1,6 +1,7 @@
package node package node
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -28,24 +28,24 @@ func TestNodeInspectErrors(t *testing.T) {
{ {
args: []string{"self"}, args: []string{"self"},
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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) { 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", expectedError: "error inspecting the node",
}, },
{ {
args: []string{"self"}, args: []string{"self"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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) { infoFunc: func() (system.Info, error) {
return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil
@ -58,7 +58,7 @@ func TestNodeInspectErrors(t *testing.T) {
"pretty": "true", "pretty": "true",
}, },
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },

View File

@ -1,6 +1,7 @@
package node package node
import ( import (
"errors"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -23,7 +23,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
}{ }{
{ {
nodeListFunc: func() ([]swarm.Node, error) { 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", expectedError: "error listing nodes",
}, },
@ -36,7 +36,7 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
}, nil }, nil
}, },
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },

View File

@ -1,13 +1,13 @@
package node package node
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -24,14 +24,14 @@ func TestNodePromoteErrors(t *testing.T) {
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting the node",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { 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", 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 { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Role != swarm.NodeRoleManager { 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 return nil
}, },
@ -74,7 +74,7 @@ func TestNodePromoteMultipleNode(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Role != swarm.NodeRoleManager { 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 return nil
}, },

View File

@ -2,6 +2,7 @@ package node
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -12,7 +13,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -29,21 +29,21 @@ func TestNodePsErrors(t *testing.T) {
}{ }{
{ {
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting the node",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { 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", expectedError: "error returning the task list",
}, },

View File

@ -1,11 +1,11 @@
package node package node
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -21,7 +21,7 @@ func TestNodeRemoveErrors(t *testing.T) {
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeRemoveFunc: func() error { nodeRemoveFunc: func() error {
return errors.Errorf("error removing the node") return errors.New("error removing the node")
}, },
expectedError: "error removing the node", expectedError: "error removing the node",
}, },

View File

@ -1,13 +1,14 @@
package node package node
import ( import (
"errors"
"fmt"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -29,14 +30,14 @@ func TestNodeUpdateErrors(t *testing.T) {
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting the node",
}, },
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { 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", 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 { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Role != swarm.NodeRoleManager { 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 return nil
}, },
@ -101,7 +102,7 @@ func TestNodeUpdate(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if node.Availability != swarm.NodeAvailabilityDrain { 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 return nil
}, },
@ -116,7 +117,7 @@ func TestNodeUpdate(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if _, present := node.Annotations.Labels["lbl"]; !present { 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 return nil
}, },
@ -131,7 +132,7 @@ func TestNodeUpdate(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if value, present := node.Annotations.Labels["key"]; !present || value != "value" { 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 return nil
}, },
@ -148,7 +149,7 @@ func TestNodeUpdate(t *testing.T) {
}, },
nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error { nodeUpdateFunc: func(nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if len(node.Annotations.Labels) > 0 { 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 return nil
}, },

View File

@ -2,12 +2,12 @@ package plugin
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/pkg/errors"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )

View File

@ -2,6 +2,8 @@ package secret
import ( import (
"context" "context"
"errors"
"fmt"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
@ -12,7 +14,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -36,7 +37,7 @@ func TestSecretCreateErrors(t *testing.T) {
{ {
args: []string{"name", filepath.Join("testdata", secretDataFile)}, args: []string{"name", filepath.Join("testdata", secretDataFile)},
secretCreateFunc: func(_ context.Context, secretSpec swarm.SecretSpec) (types.SecretCreateResponse, error) { 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", expectedError: "error creating secret",
}, },
@ -70,7 +71,7 @@ func TestSecretCreateWithName(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if !reflect.DeepEqual(spec, expected) { 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{ return types.SecretCreateResponse{
ID: "ID-" + spec.Name, ID: "ID-" + spec.Name,
@ -93,11 +94,11 @@ func TestSecretCreateWithDriver(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { 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 { 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{ return types.SecretCreateResponse{
@ -108,7 +109,7 @@ func TestSecretCreateWithDriver(t *testing.T) {
cmd := newSecretCreateCommand(cli) cmd := newSecretCreateCommand(cli)
cmd.SetArgs([]string{name}) 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.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
} }
@ -117,16 +118,16 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
expectedDriver := &swarm.Driver{ expectedDriver := &swarm.Driver{
Name: "template-driver", Name: "template-driver",
} }
name := "foo" const name = "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { 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 { 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{ return types.SecretCreateResponse{
@ -137,7 +138,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
cmd := newSecretCreateCommand(cli) cmd := newSecretCreateCommand(cli)
cmd.SetArgs([]string{name}) 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.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
} }
@ -147,16 +148,16 @@ func TestSecretCreateWithLabels(t *testing.T) {
"lbl1": "Label-foo", "lbl1": "Label-foo",
"lbl2": "Label-bar", "lbl2": "Label-bar",
} }
name := "foo" const name = "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { 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) { 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{ return types.SecretCreateResponse{
@ -167,8 +168,8 @@ func TestSecretCreateWithLabels(t *testing.T) {
cmd := newSecretCreateCommand(cli) cmd := newSecretCreateCommand(cli)
cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)}) cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)})
cmd.Flags().Set("label", "lbl1=Label-foo") assert.Check(t, cmd.Flags().Set("label", "lbl1=Label-foo"))
cmd.Flags().Set("label", "lbl2=Label-bar") assert.Check(t, cmd.Flags().Set("label", "lbl2=Label-bar"))
assert.NilError(t, cmd.Execute()) assert.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String())))
} }

View File

@ -2,6 +2,7 @@ package secret
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -28,7 +28,7 @@ func TestSecretInspectErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
secretInspectFunc: func(_ context.Context, secretID string) (swarm.Secret, []byte, error) { 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", expectedError: "error while inspecting the secret",
}, },
@ -45,7 +45,7 @@ func TestSecretInspectErrors(t *testing.T) {
if secretID == "foo" { if secretID == "foo" {
return *builders.Secret(builders.SecretName("foo")), nil, nil 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", expectedError: "error while inspecting the secret",
}, },
@ -77,7 +77,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
args: []string{"foo"}, args: []string{"foo"},
secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) {
if name != "foo" { 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 return *builders.Secret(builders.SecretID("ID-foo"), builders.SecretName("foo")), nil, nil
}, },

View File

@ -2,6 +2,7 @@ package secret
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
"time" "time"
@ -11,7 +12,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -29,7 +29,7 @@ func TestSecretListErrors(t *testing.T) {
}, },
{ {
secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { 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", expectedError: "error listing secrets",
}, },

View File

@ -2,12 +2,12 @@ package secret
import ( import (
"context" "context"
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -25,7 +25,7 @@ func TestSecretRemoveErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
secretRemoveFunc: func(_ context.Context, name string) error { secretRemoveFunc: func(_ context.Context, name string) error {
return errors.Errorf("error removing secret") return errors.New("error removing secret")
}, },
expectedError: "error removing secret", expectedError: "error removing secret",
}, },
@ -67,7 +67,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
secretRemoveFunc: func(_ context.Context, name string) error { secretRemoveFunc: func(_ context.Context, name string) error {
removedSecrets = append(removedSecrets, name) removedSecrets = append(removedSecrets, name)
if name == "foo" { if name == "foo" {
return errors.Errorf("error removing secret: %s", name) return errors.New("error removing secret: " + name)
} }
return nil return nil
}, },

View File

@ -1,6 +1,7 @@
package stack package stack
import ( import (
"errors"
"io" "io"
"testing" "testing"
@ -8,7 +9,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -34,7 +34,7 @@ func TestListErrors(t *testing.T) {
{ {
args: []string{}, args: []string{},
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { 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", expectedError: "error getting services",
}, },

View File

@ -1,6 +1,7 @@
package stack package stack
import ( import (
"errors"
"io" "io"
"testing" "testing"
"time" "time"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -33,7 +33,7 @@ func TestStackPsErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { 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", expectedError: "error getting tasks",
}, },

View File

@ -1,6 +1,7 @@
package stack package stack
import ( import (
"errors"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -27,7 +27,7 @@ func TestStackServicesErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) { 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", expectedError: "error getting services",
}, },
@ -37,7 +37,7 @@ func TestStackServicesErrors(t *testing.T) {
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
}, },
nodeListFunc: func(options types.NodeListOptions) ([]swarm.Node, error) { 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) { taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task()}, nil return []swarm.Task{*builders.Task()}, nil
@ -50,7 +50,7 @@ func TestStackServicesErrors(t *testing.T) {
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
}, },
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) { 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", expectedError: "error getting tasks",
}, },

View File

@ -2,11 +2,11 @@ package swarm
import ( import (
"context" "context"
"errors"
"testing" "testing"
"github.com/docker/cli/internal/test/network" "github.com/docker/cli/internal/test/network"
networktypes "github.com/docker/docker/api/types/network" networktypes "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "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", expectedMsg: "could not be found. You need to create a swarm-scoped network",
}, },
{ {
inspectError: errors.New("Unexpected"), inspectError: errors.New("unexpected"),
expectedMsg: "Unexpected", expectedMsg: "unexpected",
}, },
// FIXME(vdemeester) that doesn't work under windows, the check needs to be smarter // 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 { for _, testcase := range testcases {
fakeClient := &network.FakeClient{ client := &network.FakeClient{
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) { NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) {
return testcase.inspectResponse, testcase.inspectError return testcase.inspectResponse, testcase.inspectError
}, },
} }
networks := []string{testcase.network} networks := []string{testcase.network}
err := validateExternalNetworks(context.Background(), fakeClient, networks) err := validateExternalNetworks(context.Background(), client, networks)
if testcase.expectedMsg == "" { if testcase.expectedMsg == "" {
assert.NilError(t, err) assert.NilError(t, err)
} else { } else {

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -8,7 +9,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -26,28 +26,28 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
{ {
name: "init-failed", name: "init-failed",
swarmInitFunc: func() (string, error) { swarmInitFunc: func() (string, error) {
return "", errors.Errorf("error initializing the swarm") return "", errors.New("error initializing the swarm")
}, },
expectedError: "error initializing the swarm", expectedError: "error initializing the swarm",
}, },
{ {
name: "init-failed-with-ip-choice", name: "init-failed-with-ip-choice",
swarmInitFunc: func() (string, error) { 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", expectedError: "could not choose an IP address to advertise - specify one with --advertise-addr",
}, },
{ {
name: "swarm-inspect-after-init-failed", name: "swarm-inspect-after-init-failed",
swarmInspectFunc: func() (swarm.Swarm, error) { 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", expectedError: "error inspecting the swarm",
}, },
{ {
name: "node-inspect-after-init-failed", name: "node-inspect-after-init-failed",
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting the node",
}, },
@ -57,7 +57,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
flagAutolock: "true", flagAutolock: "true",
}, },
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { 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", expectedError: "could not fetch unlock key: error getting swarm unlock key",
}, },

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
@ -8,7 +9,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -34,7 +34,7 @@ func TestSwarmJoinErrors(t *testing.T) {
name: "join-failed", name: "join-failed",
args: []string{"remote"}, args: []string{"remote"},
swarmJoinFunc: func() error { swarmJoinFunc: func() error {
return errors.Errorf("error joining the swarm") return errors.New("error joining the swarm")
}, },
expectedError: "error joining the swarm", expectedError: "error joining the swarm",
}, },
@ -42,7 +42,7 @@ func TestSwarmJoinErrors(t *testing.T) {
name: "join-failed-on-init", name: "join-failed-on-init",
args: []string{"remote"}, args: []string{"remote"},
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -43,7 +43,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
name: "swarm-inspect-failed", name: "swarm-inspect-failed",
args: []string{"worker"}, args: []string{"worker"},
swarmInspectFunc: func() (swarm.Swarm, error) { 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", expectedError: "error inspecting the swarm",
}, },
@ -54,7 +54,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
flagRotate: "true", flagRotate: "true",
}, },
swarmInspectFunc: func() (swarm.Swarm, error) { 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", expectedError: "error inspecting the swarm",
}, },
@ -65,7 +65,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
flagRotate: "true", flagRotate: "true",
}, },
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { 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", expectedError: "error updating the swarm",
}, },
@ -73,7 +73,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
name: "node-inspect-failed", name: "node-inspect-failed",
args: []string{"worker"}, args: []string{"worker"},
nodeInspectFunc: func() (swarm.Node, []byte, error) { 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", expectedError: "error inspecting node",
}, },
@ -81,7 +81,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
name: "info-failed", name: "info-failed",
args: []string{"worker"}, args: []string{"worker"},
infoFunc: func() (system.Info, error) { 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", expectedError: "error asking for node info",
}, },

View File

@ -1,12 +1,12 @@
package swarm package swarm
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -26,7 +26,7 @@ func TestSwarmLeaveErrors(t *testing.T) {
{ {
name: "leave-failed", name: "leave-failed",
swarmLeaveFunc: func() error { swarmLeaveFunc: func() error {
return errors.Errorf("error leaving the swarm") return errors.New("error leaving the swarm")
}, },
expectedError: "error leaving the swarm", expectedError: "error leaving the swarm",
}, },

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -35,7 +35,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
flagRotate: "true", flagRotate: "true",
}, },
swarmInspectFunc: func() (swarm.Swarm, error) { 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", expectedError: "error inspecting the swarm",
}, },
@ -58,14 +58,14 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
return *builders.Swarm(builders.Autolock()), nil return *builders.Swarm(builders.Autolock()), nil
}, },
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { 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", expectedError: "error updating the swarm",
}, },
{ {
name: "swarm-get-unlock-key-failed", name: "swarm-get-unlock-key-failed",
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { 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", expectedError: "error getting unlock key",
}, },
@ -88,8 +88,8 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
swarmGetUnlockKeyFunc: tc.swarmGetUnlockKeyFunc, swarmGetUnlockKeyFunc: tc.swarmGetUnlockKeyFunc,
})) }))
cmd.SetArgs(tc.args) cmd.SetArgs(tc.args)
for key, value := range tc.flags { for k, v := range tc.flags {
assert.Check(t, cmd.Flags().Set(key, value)) assert.Check(t, cmd.Flags().Set(k, v))
} }
cmd.SetOut(io.Discard) cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard) cmd.SetErr(io.Discard)
@ -165,8 +165,8 @@ func TestSwarmUnlockKey(t *testing.T) {
}) })
cmd := newUnlockKeyCommand(cli) cmd := newUnlockKeyCommand(cli)
cmd.SetArgs(tc.args) cmd.SetArgs(tc.args)
for key, value := range tc.flags { for k, v := range tc.flags {
assert.Check(t, cmd.Flags().Set(key, value)) assert.Check(t, cmd.Flags().Set(k, v))
} }
assert.NilError(t, cmd.Execute()) assert.NilError(t, cmd.Execute())
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("unlockkeys-%s.golden", tc.name)) golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("unlockkeys-%s.golden", tc.name))

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"io" "io"
"strings" "strings"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -58,7 +58,7 @@ func TestSwarmUnlockErrors(t *testing.T) {
}, nil }, nil
}, },
swarmUnlockFunc: func(req swarm.UnlockRequest) error { 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", expectedError: "error unlocking the swarm",
}, },
@ -90,7 +90,7 @@ func TestSwarmUnlock(t *testing.T) {
}, },
swarmUnlockFunc: func(req swarm.UnlockRequest) error { swarmUnlockFunc: func(req swarm.UnlockRequest) error {
if req.UnlockKey != input { if req.UnlockKey != input {
return errors.Errorf("Invalid unlock key") return errors.New("invalid unlock key")
} }
return nil return nil
}, },

View File

@ -1,6 +1,7 @@
package swarm package swarm
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -36,7 +36,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
flagTaskHistoryLimit: "10", flagTaskHistoryLimit: "10",
}, },
swarmInspectFunc: func() (swarm.Swarm, error) { 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", expectedError: "error inspecting the swarm",
}, },
@ -46,7 +46,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
flagTaskHistoryLimit: "10", flagTaskHistoryLimit: "10",
}, },
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { 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", expectedError: "error updating the swarm",
}, },
@ -59,7 +59,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
return *builders.Swarm(), nil return *builders.Swarm(), nil
}, },
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) { 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", expectedError: "error getting unlock key",
}, },
@ -114,33 +114,33 @@ func TestSwarmUpdate(t *testing.T) {
}, },
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 { if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return errors.Errorf("historyLimit not correctly set") return errors.New("historyLimit not correctly set")
} }
heartbeatDuration, err := time.ParseDuration("10s") heartbeatDuration, err := time.ParseDuration("10s")
if err != nil { if err != nil {
return err return err
} }
if swarm.Dispatcher.HeartbeatPeriod != heartbeatDuration { if swarm.Dispatcher.HeartbeatPeriod != heartbeatDuration {
return errors.Errorf("heartbeatPeriodLimit not correctly set") return errors.New("heartbeatPeriodLimit not correctly set")
} }
certExpiryDuration, err := time.ParseDuration("20s") certExpiryDuration, err := time.ParseDuration("20s")
if err != nil { if err != nil {
return err return err
} }
if swarm.CAConfig.NodeCertExpiry != certExpiryDuration { 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" { 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 { if *swarm.Raft.KeepOldSnapshots != 10 {
return errors.Errorf("keepOldSnapshots not correctly set") return errors.New("keepOldSnapshots not correctly set")
} }
if swarm.Raft.SnapshotInterval != 100 { if swarm.Raft.SnapshotInterval != 100 {
return errors.Errorf("snapshotInterval not correctly set") return errors.New("snapshotInterval not correctly set")
} }
if !swarm.EncryptionConfig.AutoLockManagers { if !swarm.EncryptionConfig.AutoLockManagers {
return errors.Errorf("autolock not correctly set") return errors.New("autolock not correctly set")
} }
return nil return nil
}, },
@ -153,7 +153,7 @@ func TestSwarmUpdate(t *testing.T) {
}, },
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error { swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 { if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return errors.Errorf("historyLimit not correctly set") return errors.New("historyLimit not correctly set")
} }
return nil return nil
}, },

View File

@ -2,6 +2,7 @@ package system
import ( import (
"context" "context"
"errors"
"io" "io"
"testing" "testing"
@ -10,7 +11,6 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -17,7 +18,6 @@ import (
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )

View File

@ -1,6 +1,8 @@
package volume package volume
import ( import (
"errors"
"fmt"
"io" "io"
"reflect" "reflect"
"sort" "sort"
@ -9,7 +11,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -34,7 +35,7 @@ func TestVolumeCreateErrors(t *testing.T) {
}, },
{ {
volumeCreateFunc: func(createBody volume.CreateOptions) (volume.Volume, error) { 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", expectedError: "error creating volume",
}, },
@ -60,7 +61,7 @@ func TestVolumeCreateWithName(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) { volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
if body.Name != name { 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{ return volume.Volume{
Name: body.Name, Name: body.Name,
@ -99,16 +100,16 @@ func TestVolumeCreateWithFlags(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) { volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
if body.Name != "" { 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 { 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) { 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) { 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{ return volume.Volume{
Name: name, Name: name,

View File

@ -1,6 +1,7 @@
package volume package volume
import ( import (
"errors"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -27,7 +27,7 @@ func TestVolumeInspectErrors(t *testing.T) {
{ {
args: []string{"foo"}, args: []string{"foo"},
volumeInspectFunc: func(volumeID string) (volume.Volume, error) { 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", expectedError: "error while inspecting the volume",
}, },
@ -46,7 +46,7 @@ func TestVolumeInspectErrors(t *testing.T) {
Name: "foo", Name: "foo",
}, nil }, 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", expectedError: "error while inspecting the volume",
}, },
@ -78,7 +78,7 @@ func TestVolumeInspectWithoutFormat(t *testing.T) {
args: []string{"foo"}, args: []string{"foo"},
volumeInspectFunc: func(volumeID string) (volume.Volume, error) { volumeInspectFunc: func(volumeID string) (volume.Volume, error) {
if volumeID != "foo" { 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 return *builders.Volume(), nil
}, },

View File

@ -1,6 +1,7 @@
package volume package volume
import ( import (
"errors"
"io" "io"
"testing" "testing"
@ -9,7 +10,6 @@ import (
"github.com/docker/cli/internal/test/builders" "github.com/docker/cli/internal/test/builders"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
) )
@ -27,7 +27,7 @@ func TestVolumeListErrors(t *testing.T) {
}, },
{ {
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) { 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", expectedError: "error listing volumes",
}, },

View File

@ -2,6 +2,7 @@ package volume
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"runtime" "runtime"
@ -12,7 +13,6 @@ import (
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden" "gotest.tools/v3/golden"
@ -38,7 +38,7 @@ func TestVolumePruneErrors(t *testing.T) {
"force": "true", "force": "true",
}, },
volumePruneFunc: func(args filters.Args) (volume.PruneReport, error) { 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", expectedError: "error pruning volumes",
}, },

View File

@ -1,11 +1,11 @@
package volume package volume
import ( import (
"errors"
"io" "io"
"testing" "testing"
"github.com/docker/cli/internal/test" "github.com/docker/cli/internal/test"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
) )
@ -21,7 +21,7 @@ func TestVolumeRemoveErrors(t *testing.T) {
{ {
args: []string{"nodeID"}, args: []string{"nodeID"},
volumeRemoveFunc: func(volumeID string, force bool) error { 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", expectedError: "error removing the volume",
}, },

View File

@ -2,6 +2,7 @@ package convert
import ( import (
"context" "context"
"errors"
"os" "os"
"strings" "strings"
"testing" "testing"
@ -12,7 +13,6 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )

View File

@ -2,6 +2,7 @@ package credentials
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -10,7 +11,6 @@ import (
"github.com/docker/cli/cli/config/types" "github.com/docker/cli/cli/config/types"
"github.com/docker/docker-credential-helpers/client" "github.com/docker/docker-credential-helpers/client"
"github.com/docker/docker-credential-helpers/credentials" "github.com/docker/docker-credential-helpers/credentials"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
) )
@ -22,7 +22,7 @@ const (
missingCredsAddress = "https://missing.docker.io/v1" 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 // mockCommand simulates interactions between the docker client and a remote
// credentials helper. // credentials helper.

View File

@ -13,7 +13,6 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
"gotest.tools/v3/fs" "gotest.tools/v3/fs"
"gotest.tools/v3/icmd" "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") cmd.Env = append(os.Environ(), "CGO_ENABLED=0")
if out, err := cmd.CombinedOutput(); err != nil { 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 return installPath, nil

View File

@ -1,6 +1,7 @@
package environment package environment
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"strings" "strings"
@ -8,7 +9,6 @@ import (
"time" "time"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/pkg/errors"
"gotest.tools/v3/icmd" "gotest.tools/v3/icmd"
"gotest.tools/v3/poll" "gotest.tools/v3/poll"
"gotest.tools/v3/skip" "gotest.tools/v3/skip"

View File

@ -1,10 +1,9 @@
package output package output
import ( import (
"fmt"
"strings" "strings"
"testing" "testing"
"github.com/pkg/errors"
) )
// Assert checks output lines at specified locations // Assert checks output lines at specified locations
@ -30,7 +29,7 @@ func Prefix(expected string) func(string) error {
if strings.HasPrefix(actual, expected) { if strings.HasPrefix(actual, expected) {
return nil 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) { if strings.HasSuffix(actual, expected) {
return nil 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) { if strings.Contains(actual, expected) {
return nil 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 { if expected == actual {
return nil return nil
} }
return errors.Errorf("got %q, expected %q", actual, expected) return fmt.Errorf("got %q, expected %q", actual, expected)
} }
} }