client/container: use containerd errdefs checks

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski
2025-05-19 14:13:59 +02:00
committed by Sebastiaan van Stijn
parent eafa2266f6
commit c75ca8ef10
23 changed files with 101 additions and 101 deletions

View File

@@ -10,8 +10,8 @@ import (
"strings"
"testing"
cerrdefs "github.com/containerd/errdefs"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -22,14 +22,14 @@ func TestContainerExecCreateError(t *testing.T) {
}
_, err := client.ContainerExecCreate(context.Background(), "container_id", container.ExecOptions{})
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
_, err = client.ContainerExecCreate(context.Background(), "", container.ExecOptions{})
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
assert.Check(t, is.ErrorContains(err, "value is empty"))
_, err = client.ContainerExecCreate(context.Background(), " ", container.ExecOptions{})
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
assert.Check(t, is.ErrorContains(err, "value is empty"))
}
@@ -91,7 +91,7 @@ func TestContainerExecStartError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
}
err := client.ContainerExecStart(context.Background(), "nothing", container.ExecStartOptions{})
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
}
func TestContainerExecStart(t *testing.T) {
@@ -131,7 +131,7 @@ func TestContainerExecInspectError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
}
_, err := client.ContainerExecInspect(context.Background(), "nothing")
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
}
func TestContainerExecInspect(t *testing.T) {