cli/command/image: remove uses of pkg/errors in tests

While there may be reasons to keep pkg/errors in production code,
we don't need them for these tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-02-01 14:41:04 +01:00
parent d30c894af1
commit f29fdd3091
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
8 changed files with 17 additions and 17 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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