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>
This commit is contained in:
Sebastiaan van Stijn
2023-05-10 13:19:53 +02:00
parent 0538cdd226
commit 56fb56ccf0
3 changed files with 10 additions and 10 deletions

View File

@@ -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) {

View File

@@ -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))
})
}

View File

@@ -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)