From d6c26471d1747c811d13f8f68f514e14e41fb6da Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 1 Feb 2025 14:41:44 +0100 Subject: [PATCH] cli/command/manifest: 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 --- cli/command/manifest/create_test.go | 6 +++--- cli/command/manifest/inspect_test.go | 4 ++-- cli/command/manifest/push_test.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/command/manifest/create_test.go b/cli/command/manifest/create_test.go index c87d5d09ab..41c9b134d0 100644 --- a/cli/command/manifest/create_test.go +++ b/cli/command/manifest/create_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -9,7 +10,6 @@ import ( "github.com/docker/cli/cli/manifest/store" manifesttypes "github.com/docker/cli/cli/manifest/types" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -103,10 +103,10 @@ func TestManifestCreateNoManifest(t *testing.T) { cli.SetManifestStore(manifestStore) cli.SetRegistryClient(&fakeRegistryClient{ getManifestFunc: func(_ context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) { - return manifesttypes.ImageManifest{}, errors.Errorf("No such image: %v", ref) + return manifesttypes.ImageManifest{}, errors.New("No such image: " + ref.String()) }, getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error) { - return nil, errors.Errorf("No such manifest: %s", ref) + return nil, errors.New("No such manifest: " + ref.String()) }, }) diff --git a/cli/command/manifest/inspect_test.go b/cli/command/manifest/inspect_test.go index 0009b41770..83d6277bdb 100644 --- a/cli/command/manifest/inspect_test.go +++ b/cli/command/manifest/inspect_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -13,7 +14,6 @@ import ( "github.com/docker/distribution/manifest/schema2" "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -86,7 +86,7 @@ func TestInspectCommandNotFound(t *testing.T) { return types.ImageManifest{}, errors.New("missing") }, getManifestListFunc: func(ctx context.Context, ref reference.Named) ([]types.ImageManifest, error) { - return nil, errors.Errorf("No such manifest: %s", ref) + return nil, errors.New("No such manifest: " + ref.String()) }, }) diff --git a/cli/command/manifest/push_test.go b/cli/command/manifest/push_test.go index a10d5b24db..3f747cc6f8 100644 --- a/cli/command/manifest/push_test.go +++ b/cli/command/manifest/push_test.go @@ -2,6 +2,7 @@ package manifest import ( "context" + "errors" "io" "testing" @@ -9,17 +10,16 @@ import ( "github.com/docker/cli/cli/manifest/store" manifesttypes "github.com/docker/cli/cli/manifest/types" "github.com/docker/cli/internal/test" - "github.com/pkg/errors" "gotest.tools/v3/assert" ) func newFakeRegistryClient() *fakeRegistryClient { return &fakeRegistryClient{ getManifestFunc: func(_ context.Context, _ reference.Named) (manifesttypes.ImageManifest, error) { - return manifesttypes.ImageManifest{}, errors.New("") + return manifesttypes.ImageManifest{}, errors.New("unexpected error") }, getManifestListFunc: func(_ context.Context, _ reference.Named) ([]manifesttypes.ImageManifest, error) { - return nil, errors.Errorf("") + return nil, errors.New("unexpected error") }, } }