Skip to content

Commit 4d7fe01

Browse files
authored
Merge pull request #5781 from thaJeztah/less_pkg_errors
remove uses of pkg/errors in tests
2 parents bdd70c1 + 2e26ce1 commit 4d7fe01

71 files changed

Lines changed: 219 additions & 217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli/command/checkpoint/create_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package checkpoint
22

33
import (
4+
"errors"
45
"io"
56
"strings"
67
"testing"
78

89
"github.com/docker/cli/internal/test"
910
"github.com/docker/docker/api/types/checkpoint"
10-
"github.com/pkg/errors"
1111
"gotest.tools/v3/assert"
1212
is "gotest.tools/v3/assert/cmp"
1313
)
@@ -29,7 +29,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
2929
{
3030
args: []string{"foo", "bar"},
3131
checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error {
32-
return errors.Errorf("error creating checkpoint for container foo")
32+
return errors.New("error creating checkpoint for container foo")
3333
},
3434
expectedError: "error creating checkpoint for container foo",
3535
},

cli/command/checkpoint/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package checkpoint
22

33
import (
4+
"errors"
45
"io"
56
"testing"
67

78
"github.com/docker/cli/internal/test"
89
"github.com/docker/docker/api/types/checkpoint"
9-
"github.com/pkg/errors"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
1212
"gotest.tools/v3/golden"
@@ -29,7 +29,7 @@ func TestCheckpointListErrors(t *testing.T) {
2929
{
3030
args: []string{"foo"},
3131
checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
32-
return []checkpoint.Summary{}, errors.Errorf("error getting checkpoints for container foo")
32+
return []checkpoint.Summary{}, errors.New("error getting checkpoints for container foo")
3333
},
3434
expectedError: "error getting checkpoints for container foo",
3535
},

cli/command/checkpoint/remove_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package checkpoint
22

33
import (
4+
"errors"
45
"io"
56
"testing"
67

78
"github.com/docker/cli/internal/test"
89
"github.com/docker/docker/api/types/checkpoint"
9-
"github.com/pkg/errors"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
1212
)
@@ -28,7 +28,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
2828
{
2929
args: []string{"foo", "bar"},
3030
checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error {
31-
return errors.Errorf("error deleting checkpoint")
31+
return errors.New("error deleting checkpoint")
3232
},
3333
expectedError: "error deleting checkpoint",
3434
},

cli/command/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package command
33
import (
44
"bytes"
55
"context"
6+
"errors"
67
"fmt"
78
"io"
89
"net"
@@ -22,7 +23,6 @@ import (
2223
"github.com/docker/docker/api"
2324
"github.com/docker/docker/api/types"
2425
"github.com/docker/docker/client"
25-
"github.com/pkg/errors"
2626
"gotest.tools/v3/assert"
2727
"gotest.tools/v3/fs"
2828
)

cli/command/config/create_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package config
22

33
import (
44
"context"
5+
"errors"
6+
"fmt"
57
"io"
68
"os"
79
"path/filepath"
@@ -12,7 +14,6 @@ import (
1214
"github.com/docker/cli/internal/test"
1315
"github.com/docker/docker/api/types"
1416
"github.com/docker/docker/api/types/swarm"
15-
"github.com/pkg/errors"
1617
"gotest.tools/v3/assert"
1718
is "gotest.tools/v3/assert/cmp"
1819
"gotest.tools/v3/golden"
@@ -37,7 +38,7 @@ func TestConfigCreateErrors(t *testing.T) {
3738
{
3839
args: []string{"name", filepath.Join("testdata", configDataFile)},
3940
configCreateFunc: func(_ context.Context, configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
40-
return types.ConfigCreateResponse{}, errors.Errorf("error creating config")
41+
return types.ConfigCreateResponse{}, errors.New("error creating config")
4142
},
4243
expectedError: "error creating config",
4344
},
@@ -63,7 +64,7 @@ func TestConfigCreateWithName(t *testing.T) {
6364
cli := test.NewFakeCli(&fakeClient{
6465
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
6566
if spec.Name != name {
66-
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
67+
return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
6768
}
6869

6970
actual = spec.Data
@@ -102,7 +103,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
102103
cli := test.NewFakeCli(&fakeClient{
103104
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
104105
if !reflect.DeepEqual(spec, expected) {
105-
return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
106+
return types.ConfigCreateResponse{}, fmt.Errorf("expected %+v, got %+v", expected, spec)
106107
}
107108

108109
return types.ConfigCreateResponse{
@@ -128,11 +129,11 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
128129
cli := test.NewFakeCli(&fakeClient{
129130
configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
130131
if spec.Name != name {
131-
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
132+
return types.ConfigCreateResponse{}, fmt.Errorf("expected name %q, got %q", name, spec.Name)
132133
}
133134

134135
if spec.Templating.Name != expectedDriver.Name {
135-
return types.ConfigCreateResponse{}, errors.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
136+
return types.ConfigCreateResponse{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, spec.Labels)
136137
}
137138

138139
return types.ConfigCreateResponse{

cli/command/config/inspect_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"io"
78
"testing"
@@ -10,7 +11,6 @@ import (
1011
"github.com/docker/cli/internal/test"
1112
"github.com/docker/cli/internal/test/builders"
1213
"github.com/docker/docker/api/types/swarm"
13-
"github.com/pkg/errors"
1414
"gotest.tools/v3/assert"
1515
"gotest.tools/v3/golden"
1616
)
@@ -28,7 +28,7 @@ func TestConfigInspectErrors(t *testing.T) {
2828
{
2929
args: []string{"foo"},
3030
configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) {
31-
return swarm.Config{}, nil, errors.Errorf("error while inspecting the config")
31+
return swarm.Config{}, nil, errors.New("error while inspecting the config")
3232
},
3333
expectedError: "error while inspecting the config",
3434
},
@@ -45,7 +45,7 @@ func TestConfigInspectErrors(t *testing.T) {
4545
if configID == "foo" {
4646
return *builders.Config(builders.ConfigName("foo")), nil, nil
4747
}
48-
return swarm.Config{}, nil, errors.Errorf("error while inspecting the config")
48+
return swarm.Config{}, nil, errors.New("error while inspecting the config")
4949
},
5050
expectedError: "error while inspecting the config",
5151
},
@@ -77,7 +77,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
7777
args: []string{"foo"},
7878
configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
7979
if name != "foo" {
80-
return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
80+
return swarm.Config{}, nil, fmt.Errorf("invalid name, expected %s, got %s", "foo", name)
8181
}
8282
return *builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")), nil, nil
8383
},

cli/command/config/ls_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"context"
5+
"errors"
56
"io"
67
"testing"
78
"time"
@@ -11,7 +12,6 @@ import (
1112
"github.com/docker/cli/internal/test/builders"
1213
"github.com/docker/docker/api/types"
1314
"github.com/docker/docker/api/types/swarm"
14-
"github.com/pkg/errors"
1515
"gotest.tools/v3/assert"
1616
is "gotest.tools/v3/assert/cmp"
1717
"gotest.tools/v3/golden"
@@ -29,7 +29,7 @@ func TestConfigListErrors(t *testing.T) {
2929
},
3030
{
3131
configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
32-
return []swarm.Config{}, errors.Errorf("error listing configs")
32+
return []swarm.Config{}, errors.New("error listing configs")
3333
},
3434
expectedError: "error listing configs",
3535
},

cli/command/config/remove_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package config
22

33
import (
4+
"errors"
45
"io"
56
"strings"
67
"testing"
78

89
"github.com/docker/cli/internal/test"
9-
"github.com/pkg/errors"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
1212
)
@@ -24,7 +24,7 @@ func TestConfigRemoveErrors(t *testing.T) {
2424
{
2525
args: []string{"foo"},
2626
configRemoveFunc: func(name string) error {
27-
return errors.Errorf("error removing config")
27+
return errors.New("error removing config")
2828
},
2929
expectedError: "error removing config",
3030
},
@@ -66,7 +66,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
6666
configRemoveFunc: func(name string) error {
6767
removedConfigs = append(removedConfigs, name)
6868
if name == "foo" {
69-
return errors.Errorf("error removing config: %s", name)
69+
return errors.New("error removing config: " + name)
7070
}
7171
return nil
7272
},

cli/command/container/attach_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package container
22

33
import (
4+
"errors"
45
"io"
56
"testing"
67

78
"github.com/docker/cli/cli"
89
"github.com/docker/cli/internal/test"
910
"github.com/docker/docker/api/types/container"
10-
"github.com/pkg/errors"
1111
"gotest.tools/v3/assert"
1212
)
1313

@@ -23,7 +23,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
2323
args: []string{"5cb5bb5e4a3b"},
2424
expectedError: "something went wrong",
2525
containerInspectFunc: func(containerID string) (container.InspectResponse, error) {
26-
return container.InspectResponse{}, errors.Errorf("something went wrong")
26+
return container.InspectResponse{}, errors.New("something went wrong")
2727
},
2828
},
2929
{

cli/command/container/commit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package container
22

33
import (
44
"context"
5+
"errors"
56
"io"
67
"testing"
78

89
"github.com/docker/cli/internal/test"
910
"github.com/docker/docker/api/types"
1011
"github.com/docker/docker/api/types/container"
11-
"github.com/pkg/errors"
1212
"gotest.tools/v3/assert"
1313
is "gotest.tools/v3/assert/cmp"
1414
)

0 commit comments

Comments
 (0)