summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2023-05-10 13:19:53 +0200
committerSebastiaan van Stijn <github@gone.nl>2023-05-10 22:13:50 +0200
commit56fb56ccf030746bcdcf9803df0f848c156a4592 (patch)
tree58fc098701677a2f60ed6bcaf29aee08fa30996b
parent0538cdd226e0394aa604b8f36f4a3cd98c27e56f (diff)
downloaddocker-56fb56ccf030746bcdcf9803df0f848c156a4592.tar.gz
integration: update error-assertions in tests
- use is.ErrorType - replace uses of client.IsErrNotFound for errdefs.IsNotFound, as the client no longer returns the old error-type. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
-rw-r--r--integration/container/copy_test.go12
-rw-r--r--integration/container/create_test.go5
-rw-r--r--integration/internal/container/states.go3
3 files changed, 10 insertions, 10 deletions
diff --git a/integration/container/copy_test.go b/integration/container/copy_test.go
index 5214d15be9..041aaa25ed 100644
--- a/integration/container/copy_test.go
+++ b/integration/container/copy_test.go
@@ -11,7 +11,7 @@ import (
"testing"
"github.com/docker/docker/api/types"
- "github.com/docker/docker/client"
+ "github.com/docker/docker/errdefs"
"github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/jsonmessage"
@@ -29,8 +29,8 @@ func TestCopyFromContainerPathDoesNotExist(t *testing.T) {
cid := container.Create(ctx, t, apiclient)
_, _, err := apiclient.CopyFromContainer(ctx, cid, "/dne")
- assert.Check(t, client.IsErrNotFound(err))
- assert.ErrorContains(t, err, "Could not find the file /dne in container "+cid)
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
+ assert.Check(t, is.ErrorContains(err, "Could not find the file /dne in container "+cid))
}
func TestCopyFromContainerPathIsNotDir(t *testing.T) {
@@ -58,8 +58,8 @@ func TestCopyToContainerPathDoesNotExist(t *testing.T) {
cid := container.Create(ctx, t, apiclient)
err := apiclient.CopyToContainer(ctx, cid, "/dne", nil, types.CopyToContainerOptions{})
- assert.Check(t, client.IsErrNotFound(err))
- assert.ErrorContains(t, err, "Could not find the file /dne in container "+cid)
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
+ assert.Check(t, is.ErrorContains(err, "Could not find the file /dne in container "+cid))
}
func TestCopyEmptyFile(t *testing.T) {
@@ -115,7 +115,7 @@ func TestCopyToContainerPathIsNotDir(t *testing.T) {
path = "c:/windows/system32/drivers/etc/hosts/"
}
err := apiclient.CopyToContainer(ctx, cid, path, nil, types.CopyToContainerOptions{})
- assert.Assert(t, is.ErrorContains(err, "not a directory"))
+ assert.Check(t, is.ErrorContains(err, "not a directory"))
}
func TestCopyFromContainer(t *testing.T) {
diff --git a/integration/container/create_test.go b/integration/container/create_test.go
index eabb2a69b5..89c28b1887 100644
--- a/integration/container/create_test.go
+++ b/integration/container/create_test.go
@@ -13,7 +13,6 @@ import (
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
- "github.com/docker/docker/client"
"github.com/docker/docker/errdefs"
ctr "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/oci"
@@ -481,7 +480,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
Variant: img.Variant,
}
_, err := c.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "")
- assert.Assert(t, client.IsErrNotFound(err), err)
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
})
t.Run("different cpu arch", func(t *testing.T) {
p := ocispec.Platform{
@@ -490,7 +489,7 @@ func TestCreateDifferentPlatform(t *testing.T) {
Variant: img.Variant,
}
_, err := c.ContainerCreate(ctx, &containertypes.Config{Image: "busybox:latest"}, &containertypes.HostConfig{}, nil, &p, "")
- assert.Assert(t, client.IsErrNotFound(err), err)
+ assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
})
}
diff --git a/integration/internal/container/states.go b/integration/internal/container/states.go
index 0671b679e8..f2eb797ab7 100644
--- a/integration/internal/container/states.go
+++ b/integration/internal/container/states.go
@@ -5,6 +5,7 @@ import (
"strings"
"github.com/docker/docker/client"
+ "github.com/docker/docker/errdefs"
"github.com/pkg/errors"
"gotest.tools/v3/poll"
)
@@ -63,7 +64,7 @@ func IsRemoved(ctx context.Context, cli client.APIClient, containerID string) fu
return func(log poll.LogT) poll.Result {
inspect, err := cli.ContainerInspect(ctx, containerID)
if err != nil {
- if client.IsErrNotFound(err) {
+ if errdefs.IsNotFound(err) {
return poll.Success()
}
return poll.Error(err)