client: 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:17:40 +02:00
parent 685b3d820a
commit 66ff1e063e
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
93 changed files with 282 additions and 392 deletions

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestCheckpointCreateError(t *testing.T) { func TestCheckpointCreateError(t *testing.T) {
@ -23,9 +25,7 @@ func TestCheckpointCreateError(t *testing.T) {
Exit: true, Exit: true,
}) })
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestCheckpointCreate(t *testing.T) { func TestCheckpointCreate(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestCheckpointDeleteError(t *testing.T) { func TestCheckpointDeleteError(t *testing.T) {
@ -22,9 +24,7 @@ func TestCheckpointDeleteError(t *testing.T) {
CheckpointID: "checkpoint_id", CheckpointID: "checkpoint_id",
}) })
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestCheckpointDelete(t *testing.T) { func TestCheckpointDelete(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestCheckpointListError(t *testing.T) { func TestCheckpointListError(t *testing.T) {
@ -20,9 +22,7 @@ func TestCheckpointListError(t *testing.T) {
} }
_, err := client.CheckpointList(context.Background(), "container_id", types.CheckpointListOptions{}) _, err := client.CheckpointList(context.Background(), "container_id", types.CheckpointListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestCheckpointList(t *testing.T) { func TestCheckpointList(t *testing.T) {
@ -63,7 +63,5 @@ func TestCheckpointListContainerNotFound(t *testing.T) {
} }
_, err := client.CheckpointList(context.Background(), "unknown", types.CheckpointListOptions{}) _, err := client.CheckpointList(context.Background(), "unknown", types.CheckpointListOptions{})
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a containerNotFound error, got %v", err)
}
} }

View file

@ -32,9 +32,7 @@ func TestConfigCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ConfigCreate(context.Background(), swarm.ConfigSpec{}) _, err := client.ConfigCreate(context.Background(), swarm.ConfigSpec{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestConfigCreate(t *testing.T) { func TestConfigCreate(t *testing.T) {

View file

@ -23,9 +23,7 @@ func TestConfigInspectNotFound(t *testing.T) {
} }
_, _, err := client.ConfigInspectWithRaw(context.Background(), "unknown") _, _, err := client.ConfigInspectWithRaw(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a NotFoundError error, got %v", err)
}
} }
func TestConfigInspectWithEmptyID(t *testing.T) { func TestConfigInspectWithEmptyID(t *testing.T) {
@ -35,9 +33,7 @@ func TestConfigInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.ConfigInspectWithRaw(context.Background(), "") _, _, err := client.ConfigInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestConfigInspectUnsupported(t *testing.T) { func TestConfigInspectUnsupported(t *testing.T) {
@ -56,9 +52,7 @@ func TestConfigInspectError(t *testing.T) {
} }
_, _, err := client.ConfigInspectWithRaw(context.Background(), "nothing") _, _, err := client.ConfigInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestConfigInspectConfigNotFound(t *testing.T) { func TestConfigInspectConfigNotFound(t *testing.T) {
@ -68,9 +62,7 @@ func TestConfigInspectConfigNotFound(t *testing.T) {
} }
_, _, err := client.ConfigInspectWithRaw(context.Background(), "unknown") _, _, err := client.ConfigInspectWithRaw(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a configNotFoundError error, got %v", err)
}
} }
func TestConfigInspect(t *testing.T) { func TestConfigInspect(t *testing.T) {

View file

@ -34,9 +34,7 @@ func TestConfigListError(t *testing.T) {
} }
_, err := client.ConfigList(context.Background(), types.ConfigListOptions{}) _, err := client.ConfigList(context.Background(), types.ConfigListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestConfigList(t *testing.T) { func TestConfigList(t *testing.T) {

View file

@ -30,9 +30,7 @@ func TestConfigRemoveError(t *testing.T) {
} }
err := client.ConfigRemove(context.Background(), "config_id") err := client.ConfigRemove(context.Background(), "config_id")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestConfigRemove(t *testing.T) { func TestConfigRemove(t *testing.T) {

View file

@ -31,9 +31,7 @@ func TestConfigUpdateError(t *testing.T) {
} }
err := client.ConfigUpdate(context.Background(), "config_id", swarm.Version{}, swarm.ConfigSpec{}) err := client.ConfigUpdate(context.Background(), "config_id", swarm.Version{}, swarm.ConfigSpec{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestConfigUpdate(t *testing.T) { func TestConfigUpdate(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerCommitError(t *testing.T) { func TestContainerCommitError(t *testing.T) {
@ -19,9 +21,7 @@ func TestContainerCommitError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerCommit(context.Background(), "nothing", types.ContainerCommitOptions{}) _, err := client.ContainerCommit(context.Background(), "nothing", types.ContainerCommitOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerCommit(t *testing.T) { func TestContainerCommit(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerStatPathError(t *testing.T) { func TestContainerStatPathError(t *testing.T) {
@ -20,9 +22,7 @@ func TestContainerStatPathError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerStatPath(context.Background(), "container_id", "path") _, err := client.ContainerStatPath(context.Background(), "container_id", "path")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerStatPathNotFoundError(t *testing.T) { func TestContainerStatPathNotFoundError(t *testing.T) {
@ -30,9 +30,7 @@ func TestContainerStatPathNotFoundError(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "Not found")), client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
} }
_, err := client.ContainerStatPath(context.Background(), "container_id", "path") _, err := client.ContainerStatPath(context.Background(), "container_id", "path")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a not found error, got %v", err)
}
} }
func TestContainerStatPathNoHeaderError(t *testing.T) { func TestContainerStatPathNoHeaderError(t *testing.T) {
@ -100,9 +98,7 @@ func TestCopyToContainerError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{}) err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestCopyToContainerNotFoundError(t *testing.T) { func TestCopyToContainerNotFoundError(t *testing.T) {
@ -110,9 +106,7 @@ func TestCopyToContainerNotFoundError(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "Not found")), client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
} }
err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{}) err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{})
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a not found error, got %v", err)
}
} }
// TestCopyToContainerEmptyResponse verifies that no error is returned when a // TestCopyToContainerEmptyResponse verifies that no error is returned when a
@ -178,9 +172,7 @@ func TestCopyFromContainerError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file") _, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestCopyFromContainerNotFoundError(t *testing.T) { func TestCopyFromContainerNotFoundError(t *testing.T) {
@ -188,9 +180,7 @@ func TestCopyFromContainerNotFoundError(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "Not found")), client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
} }
_, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file") _, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a not found error, got %v", err)
}
} }
// TestCopyFromContainerEmptyResponse verifies that no error is returned when a // TestCopyFromContainerEmptyResponse verifies that no error is returned when a

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerCreateError(t *testing.T) { func TestContainerCreateError(t *testing.T) {
@ -19,18 +21,14 @@ func TestContainerCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerCreate(context.Background(), nil, nil, nil, nil, "nothing") _, err := client.ContainerCreate(context.Background(), nil, nil, nil, nil, "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error while testing StatusInternalServerError, got %T", err)
}
// 404 doesn't automatically means an unknown image // 404 doesn't automatically means an unknown image
client = &Client{ client = &Client{
client: newMockClient(errorMock(http.StatusNotFound, "Server error")), client: newMockClient(errorMock(http.StatusNotFound, "Server error")),
} }
_, err = client.ContainerCreate(context.Background(), nil, nil, nil, nil, "nothing") _, err = client.ContainerCreate(context.Background(), nil, nil, nil, nil, "nothing")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a Server Error while testing StatusNotFound, got %T", err)
}
} }
func TestContainerCreateImageNotFound(t *testing.T) { func TestContainerCreateImageNotFound(t *testing.T) {
@ -38,9 +36,7 @@ func TestContainerCreateImageNotFound(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "No such image")), client: newMockClient(errorMock(http.StatusNotFound, "No such image")),
} }
_, err := client.ContainerCreate(context.Background(), &container.Config{Image: "unknown_image"}, nil, nil, nil, "unknown") _, err := client.ContainerCreate(context.Background(), &container.Config{Image: "unknown_image"}, nil, nil, nil, "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected an imageNotFound error, got %v, %T", err, err)
}
} }
func TestContainerCreateWithName(t *testing.T) { func TestContainerCreateWithName(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerExecCreateError(t *testing.T) { func TestContainerExecCreateError(t *testing.T) {
@ -19,9 +21,7 @@ func TestContainerExecCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerExecCreate(context.Background(), "container_id", types.ExecConfig{}) _, err := client.ContainerExecCreate(context.Background(), "container_id", types.ExecConfig{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerExecCreate(t *testing.T) { func TestContainerExecCreate(t *testing.T) {
@ -74,9 +74,7 @@ func TestContainerExecStartError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerExecStart(context.Background(), "nothing", types.ExecStartCheck{}) err := client.ContainerExecStart(context.Background(), "nothing", types.ExecStartCheck{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerExecStart(t *testing.T) { func TestContainerExecStart(t *testing.T) {
@ -118,9 +116,7 @@ func TestContainerExecInspectError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerExecInspect(context.Background(), "nothing") _, err := client.ContainerExecInspect(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerExecInspect(t *testing.T) { func TestContainerExecInspect(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerExportError(t *testing.T) { func TestContainerExportError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerExportError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerExport(context.Background(), "nothing") _, err := client.ContainerExport(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerExport(t *testing.T) { func TestContainerExport(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerInspectError(t *testing.T) { func TestContainerInspectError(t *testing.T) {
@ -21,9 +23,7 @@ func TestContainerInspectError(t *testing.T) {
} }
_, err := client.ContainerInspect(context.Background(), "nothing") _, err := client.ContainerInspect(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerInspectContainerNotFound(t *testing.T) { func TestContainerInspectContainerNotFound(t *testing.T) {
@ -32,9 +32,7 @@ func TestContainerInspectContainerNotFound(t *testing.T) {
} }
_, err := client.ContainerInspect(context.Background(), "unknown") _, err := client.ContainerInspect(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a containerNotFound error, got %v", err)
}
} }
func TestContainerInspectWithEmptyID(t *testing.T) { func TestContainerInspectWithEmptyID(t *testing.T) {
@ -44,9 +42,7 @@ func TestContainerInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.ContainerInspectWithRaw(context.Background(), "", true) _, _, err := client.ContainerInspectWithRaw(context.Background(), "", true)
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestContainerInspect(t *testing.T) { func TestContainerInspect(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerKillError(t *testing.T) { func TestContainerKillError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerKillError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerKill(context.Background(), "nothing", "SIGKILL") err := client.ContainerKill(context.Background(), "nothing", "SIGKILL")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerKill(t *testing.T) { func TestContainerKill(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerListError(t *testing.T) { func TestContainerListError(t *testing.T) {
@ -20,9 +22,7 @@ func TestContainerListError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) _, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerList(t *testing.T) { func TestContainerList(t *testing.T) {

View file

@ -23,9 +23,7 @@ func TestContainerLogsNotFoundError(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "Not found")), client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
} }
_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{}) _, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a not found error, got %v", err)
}
} }
func TestContainerLogsError(t *testing.T) { func TestContainerLogsError(t *testing.T) {
@ -33,9 +31,8 @@ func TestContainerLogsError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{}) _, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
_, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{ _, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{
Since: "2006-01-02TZ", Since: "2006-01-02TZ",
}) })

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerPauseError(t *testing.T) { func TestContainerPauseError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerPauseError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerPause(context.Background(), "nothing") err := client.ContainerPause(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerPause(t *testing.T) { func TestContainerPause(t *testing.T) {

View file

@ -24,9 +24,7 @@ func TestContainersPruneError(t *testing.T) {
} }
_, err := client.ContainersPrune(context.Background(), filters.Args{}) _, err := client.ContainersPrune(context.Background(), filters.Args{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainersPrune(t *testing.T) { func TestContainersPrune(t *testing.T) {

View file

@ -12,6 +12,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerRemoveError(t *testing.T) { func TestContainerRemoveError(t *testing.T) {
@ -19,9 +20,7 @@ func TestContainerRemoveError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerRemoveNotFoundError(t *testing.T) { func TestContainerRemoveNotFoundError(t *testing.T) {
@ -29,8 +28,8 @@ func TestContainerRemoveNotFoundError(t *testing.T) {
client: newMockClient(errorMock(http.StatusNotFound, "no such container: container_id")), client: newMockClient(errorMock(http.StatusNotFound, "no such container: container_id")),
} }
err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{}) err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{})
assert.ErrorContains(t, err, "no such container: container_id") assert.Check(t, is.ErrorContains(err, "no such container: container_id"))
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
} }
func TestContainerRemove(t *testing.T) { func TestContainerRemove(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerRenameError(t *testing.T) { func TestContainerRenameError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerRenameError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerRename(context.Background(), "nothing", "newNothing") err := client.ContainerRename(context.Background(), "nothing", "newNothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerRename(t *testing.T) { func TestContainerRename(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerResizeError(t *testing.T) { func TestContainerResizeError(t *testing.T) {
@ -18,9 +20,7 @@ func TestContainerResizeError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{}) err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerExecResizeError(t *testing.T) { func TestContainerExecResizeError(t *testing.T) {
@ -28,9 +28,7 @@ func TestContainerExecResizeError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{}) err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerResize(t *testing.T) { func TestContainerResize(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerRestartError(t *testing.T) { func TestContainerRestartError(t *testing.T) {
@ -18,9 +20,7 @@ func TestContainerRestartError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerRestart(context.Background(), "nothing", container.StopOptions{}) err := client.ContainerRestart(context.Background(), "nothing", container.StopOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerRestart(t *testing.T) { func TestContainerRestart(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerStartError(t *testing.T) { func TestContainerStartError(t *testing.T) {
@ -19,9 +21,7 @@ func TestContainerStartError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerStart(context.Background(), "nothing", types.ContainerStartOptions{}) err := client.ContainerStart(context.Background(), "nothing", types.ContainerStartOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerStart(t *testing.T) { func TestContainerStart(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerStatsError(t *testing.T) { func TestContainerStatsError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerStatsError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerStats(context.Background(), "nothing", false) _, err := client.ContainerStats(context.Background(), "nothing", false)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerStats(t *testing.T) { func TestContainerStats(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerStopError(t *testing.T) { func TestContainerStopError(t *testing.T) {
@ -18,9 +20,7 @@ func TestContainerStopError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerStop(context.Background(), "nothing", container.StopOptions{}) err := client.ContainerStop(context.Background(), "nothing", container.StopOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerStop(t *testing.T) { func TestContainerStop(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerTopError(t *testing.T) { func TestContainerTopError(t *testing.T) {
@ -20,9 +22,7 @@ func TestContainerTopError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerTop(context.Background(), "nothing", []string{}) _, err := client.ContainerTop(context.Background(), "nothing", []string{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerTop(t *testing.T) { func TestContainerTop(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerUnpauseError(t *testing.T) { func TestContainerUnpauseError(t *testing.T) {
@ -17,9 +19,7 @@ func TestContainerUnpauseError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
err := client.ContainerUnpause(context.Background(), "nothing") err := client.ContainerUnpause(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerUnpause(t *testing.T) { func TestContainerUnpause(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerUpdateError(t *testing.T) { func TestContainerUpdateError(t *testing.T) {
@ -19,9 +21,7 @@ func TestContainerUpdateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerUpdate(context.Background(), "nothing", container.UpdateConfig{}) _, err := client.ContainerUpdate(context.Background(), "nothing", container.UpdateConfig{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestContainerUpdate(t *testing.T) { func TestContainerUpdate(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestContainerWaitError(t *testing.T) { func TestContainerWaitError(t *testing.T) {
@ -25,9 +27,7 @@ func TestContainerWaitError(t *testing.T) {
case result := <-resultC: case result := <-resultC:
t.Fatalf("expected to not get a wait result, got %d", result.StatusCode) t.Fatalf("expected to not get a wait result, got %d", result.StatusCode)
case err := <-errC: case err := <-errC:
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
} }

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestDiskUsageError(t *testing.T) { func TestDiskUsageError(t *testing.T) {
@ -19,9 +21,7 @@ func TestDiskUsageError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.DiskUsage(context.Background(), types.DiskUsageOptions{}) _, err := client.DiskUsage(context.Background(), types.DiskUsageOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestDiskUsage(t *testing.T) { func TestDiskUsage(t *testing.T) {

View file

@ -5,6 +5,7 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -26,7 +27,5 @@ func TestDistributionInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, err := client.DistributionInspect(context.Background(), "", "") _, err := client.DistributionInspect(context.Background(), "", "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestEventsErrorInOptions(t *testing.T) { func TestEventsErrorInOptions(t *testing.T) {
@ -52,9 +54,7 @@ func TestEventsErrorFromServer(t *testing.T) {
} }
_, errs := client.Events(context.Background(), types.EventsOptions{}) _, errs := client.Events(context.Background(), types.EventsOptions{})
err := <-errs err := <-errs
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestEvents(t *testing.T) { func TestEvents(t *testing.T) {

View file

@ -15,6 +15,8 @@ import (
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
units "github.com/docker/go-units" units "github.com/docker/go-units"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageBuildError(t *testing.T) { func TestImageBuildError(t *testing.T) {
@ -22,9 +24,7 @@ func TestImageBuildError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageBuild(context.Background(), nil, types.ImageBuildOptions{}) _, err := client.ImageBuild(context.Background(), nil, types.ImageBuildOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageBuild(t *testing.T) { func TestImageBuild(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageCreateError(t *testing.T) { func TestImageCreateError(t *testing.T) {
@ -19,9 +21,7 @@ func TestImageCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageCreate(context.Background(), "reference", types.ImageCreateOptions{}) _, err := client.ImageCreate(context.Background(), "reference", types.ImageCreateOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageCreate(t *testing.T) { func TestImageCreate(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/image"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageHistoryError(t *testing.T) { func TestImageHistoryError(t *testing.T) {
@ -19,9 +21,7 @@ func TestImageHistoryError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageHistory(context.Background(), "nothing") _, err := client.ImageHistory(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageHistory(t *testing.T) { func TestImageHistory(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageImportError(t *testing.T) { func TestImageImportError(t *testing.T) {
@ -19,9 +21,7 @@ func TestImageImportError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", types.ImageImportOptions{}) _, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", types.ImageImportOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageImport(t *testing.T) { func TestImageImport(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageInspectError(t *testing.T) { func TestImageInspectError(t *testing.T) {
@ -22,9 +24,7 @@ func TestImageInspectError(t *testing.T) {
} }
_, _, err := client.ImageInspectWithRaw(context.Background(), "nothing") _, _, err := client.ImageInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageInspectImageNotFound(t *testing.T) { func TestImageInspectImageNotFound(t *testing.T) {
@ -33,9 +33,7 @@ func TestImageInspectImageNotFound(t *testing.T) {
} }
_, _, err := client.ImageInspectWithRaw(context.Background(), "unknown") _, _, err := client.ImageInspectWithRaw(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected an imageNotFound error, got %v", err)
}
} }
func TestImageInspectWithEmptyID(t *testing.T) { func TestImageInspectWithEmptyID(t *testing.T) {
@ -45,9 +43,7 @@ func TestImageInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.ImageInspectWithRaw(context.Background(), "") _, _, err := client.ImageInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestImageInspect(t *testing.T) { func TestImageInspect(t *testing.T) {

View file

@ -24,9 +24,7 @@ func TestImageListError(t *testing.T) {
} }
_, err := client.ImageList(context.Background(), types.ImageListOptions{}) _, err := client.ImageList(context.Background(), types.ImageListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageList(t *testing.T) { func TestImageList(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageLoadError(t *testing.T) { func TestImageLoadError(t *testing.T) {
@ -18,9 +20,7 @@ func TestImageLoadError(t *testing.T) {
} }
_, err := client.ImageLoad(context.Background(), nil, true) _, err := client.ImageLoad(context.Background(), nil, true)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageLoad(t *testing.T) { func TestImageLoad(t *testing.T) {

View file

@ -25,9 +25,7 @@ func TestImagesPruneError(t *testing.T) {
} }
_, err := client.ImagesPrune(context.Background(), filters.NewArgs()) _, err := client.ImagesPrune(context.Background(), filters.NewArgs())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImagesPrune(t *testing.T) { func TestImagesPrune(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImagePullReferenceParseError(t *testing.T) { func TestImagePullReferenceParseError(t *testing.T) {
@ -32,9 +34,7 @@ func TestImagePullAnyError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{}) _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePullStatusUnauthorizedError(t *testing.T) { func TestImagePullStatusUnauthorizedError(t *testing.T) {
@ -42,9 +42,7 @@ func TestImagePullStatusUnauthorizedError(t *testing.T) {
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
} }
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{}) _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{})
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { func TestImagePullWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
@ -72,9 +70,7 @@ func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{ _, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{
PrivilegeFunc: privilegeFunc, PrivilegeFunc: privilegeFunc,
}) })
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePullWithPrivilegedFuncNoError(t *testing.T) { func TestImagePullWithPrivilegedFuncNoError(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImagePushReferenceError(t *testing.T) { func TestImagePushReferenceError(t *testing.T) {
@ -37,9 +39,7 @@ func TestImagePushAnyError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{}) _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePushStatusUnauthorizedError(t *testing.T) { func TestImagePushStatusUnauthorizedError(t *testing.T) {
@ -47,9 +47,7 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) {
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
} }
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{}) _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { func TestImagePushWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
@ -77,9 +75,7 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{ _, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{
PrivilegeFunc: privilegeFunc, PrivilegeFunc: privilegeFunc,
}) })
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImagePushWithPrivilegedFuncNoError(t *testing.T) { func TestImagePushWithPrivilegedFuncNoError(t *testing.T) {

View file

@ -13,6 +13,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageRemoveError(t *testing.T) { func TestImageRemoveError(t *testing.T) {
@ -21,9 +22,7 @@ func TestImageRemoveError(t *testing.T) {
} }
_, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{}) _, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageRemoveImageNotFound(t *testing.T) { func TestImageRemoveImageNotFound(t *testing.T) {
@ -32,8 +31,8 @@ func TestImageRemoveImageNotFound(t *testing.T) {
} }
_, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{}) _, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{})
assert.ErrorContains(t, err, "no such image: unknown") assert.Check(t, is.ErrorContains(err, "no such image: unknown"))
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
} }
func TestImageRemove(t *testing.T) { func TestImageRemove(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageSaveError(t *testing.T) { func TestImageSaveError(t *testing.T) {
@ -18,9 +20,7 @@ func TestImageSaveError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageSave(context.Background(), []string{"nothing"}) _, err := client.ImageSave(context.Background(), []string{"nothing"})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageSave(t *testing.T) { func TestImageSave(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageSearchAnyError(t *testing.T) { func TestImageSearchAnyError(t *testing.T) {
@ -21,9 +23,7 @@ func TestImageSearchAnyError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{}) _, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestImageSearchStatusUnauthorizedError(t *testing.T) { func TestImageSearchStatusUnauthorizedError(t *testing.T) {
@ -31,9 +31,7 @@ func TestImageSearchStatusUnauthorizedError(t *testing.T) {
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")), client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
} }
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{}) _, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) { func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
@ -61,9 +59,7 @@ func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{ _, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{
PrivilegeFunc: privilegeFunc, PrivilegeFunc: privilegeFunc,
}) })
if !errdefs.IsUnauthorized(err) { assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
}
} }
func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) { func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestImageTagError(t *testing.T) { func TestImageTagError(t *testing.T) {
@ -18,9 +20,7 @@ func TestImageTagError(t *testing.T) {
} }
err := client.ImageTag(context.Background(), "image_id", "repo:tag") err := client.ImageTag(context.Background(), "image_id", "repo:tag")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
// Note: this is not testing all the InvalidReference as it's the responsibility // Note: this is not testing all the InvalidReference as it's the responsibility

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestInfoServerError(t *testing.T) { func TestInfoServerError(t *testing.T) {
@ -19,9 +21,7 @@ func TestInfoServerError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.Info(context.Background()) _, err := client.Info(context.Background())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestInfoInvalidResponseJSONError(t *testing.T) { func TestInfoInvalidResponseJSONError(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkConnectError(t *testing.T) { func TestNetworkConnectError(t *testing.T) {
@ -21,9 +23,7 @@ func TestNetworkConnectError(t *testing.T) {
} }
err := client.NetworkConnect(context.Background(), "network_id", "container_id", nil) err := client.NetworkConnect(context.Background(), "network_id", "container_id", nil)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) { func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkCreateError(t *testing.T) { func TestNetworkCreateError(t *testing.T) {
@ -20,9 +22,7 @@ func TestNetworkCreateError(t *testing.T) {
} }
_, err := client.NetworkCreate(context.Background(), "mynetwork", types.NetworkCreate{}) _, err := client.NetworkCreate(context.Background(), "mynetwork", types.NetworkCreate{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworkCreate(t *testing.T) { func TestNetworkCreate(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkDisconnectError(t *testing.T) { func TestNetworkDisconnectError(t *testing.T) {
@ -20,9 +22,7 @@ func TestNetworkDisconnectError(t *testing.T) {
} }
err := client.NetworkDisconnect(context.Background(), "network_id", "container_id", false) err := client.NetworkDisconnect(context.Background(), "network_id", "container_id", false)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworkDisconnect(t *testing.T) { func TestNetworkDisconnect(t *testing.T) {

View file

@ -14,6 +14,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkInspect(t *testing.T) { func TestNetworkInspect(t *testing.T) {
@ -69,7 +70,7 @@ func TestNetworkInspect(t *testing.T) {
t.Run("empty ID", func(t *testing.T) { t.Run("empty ID", func(t *testing.T) {
// verify that the client does not create a request if the network-ID/name is empty. // verify that the client does not create a request if the network-ID/name is empty.
_, err := client.NetworkInspect(context.Background(), "", types.NetworkInspectOptions{}) _, err := client.NetworkInspect(context.Background(), "", types.NetworkInspectOptions{})
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
}) })
t.Run("no options", func(t *testing.T) { t.Run("no options", func(t *testing.T) {
r, err := client.NetworkInspect(context.Background(), "network_id", types.NetworkInspectOptions{}) r, err := client.NetworkInspect(context.Background(), "network_id", types.NetworkInspectOptions{})
@ -87,17 +88,17 @@ func TestNetworkInspect(t *testing.T) {
}) })
t.Run("global scope", func(t *testing.T) { t.Run("global scope", func(t *testing.T) {
_, err := client.NetworkInspect(context.Background(), "network_id", types.NetworkInspectOptions{Scope: "global"}) _, err := client.NetworkInspect(context.Background(), "network_id", types.NetworkInspectOptions{Scope: "global"})
assert.ErrorContains(t, err, "Error: No such network: network_id") assert.Check(t, is.ErrorContains(err, "Error: No such network: network_id"))
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
}) })
t.Run("unknown network", func(t *testing.T) { t.Run("unknown network", func(t *testing.T) {
_, err := client.NetworkInspect(context.Background(), "unknown", types.NetworkInspectOptions{}) _, err := client.NetworkInspect(context.Background(), "unknown", types.NetworkInspectOptions{})
assert.ErrorContains(t, err, "Error: No such network: unknown") assert.Check(t, is.ErrorContains(err, "Error: No such network: unknown"))
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
}) })
t.Run("server error", func(t *testing.T) { t.Run("server error", func(t *testing.T) {
// Just testing that an internal server error is converted correctly by the client // Just testing that an internal server error is converted correctly by the client
_, err := client.NetworkInspect(context.Background(), "test-500-response", types.NetworkInspectOptions{}) _, err := client.NetworkInspect(context.Background(), "test-500-response", types.NetworkInspectOptions{})
assert.Check(t, errdefs.IsSystem(err)) assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
}) })
} }

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkListError(t *testing.T) { func TestNetworkListError(t *testing.T) {
@ -21,9 +23,7 @@ func TestNetworkListError(t *testing.T) {
} }
_, err := client.NetworkList(context.Background(), types.NetworkListOptions{}) _, err := client.NetworkList(context.Background(), types.NetworkListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworkList(t *testing.T) { func TestNetworkList(t *testing.T) {

View file

@ -24,9 +24,7 @@ func TestNetworksPruneError(t *testing.T) {
} }
_, err := client.NetworksPrune(context.Background(), filters.NewArgs()) _, err := client.NetworksPrune(context.Background(), filters.NewArgs())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworksPrune(t *testing.T) { func TestNetworksPrune(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNetworkRemoveError(t *testing.T) { func TestNetworkRemoveError(t *testing.T) {
@ -18,9 +20,7 @@ func TestNetworkRemoveError(t *testing.T) {
} }
err := client.NetworkRemove(context.Background(), "network_id") err := client.NetworkRemove(context.Background(), "network_id")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNetworkRemove(t *testing.T) { func TestNetworkRemove(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNodeInspectError(t *testing.T) { func TestNodeInspectError(t *testing.T) {
@ -21,9 +23,7 @@ func TestNodeInspectError(t *testing.T) {
} }
_, _, err := client.NodeInspectWithRaw(context.Background(), "nothing") _, _, err := client.NodeInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNodeInspectNodeNotFound(t *testing.T) { func TestNodeInspectNodeNotFound(t *testing.T) {
@ -32,9 +32,7 @@ func TestNodeInspectNodeNotFound(t *testing.T) {
} }
_, _, err := client.NodeInspectWithRaw(context.Background(), "unknown") _, _, err := client.NodeInspectWithRaw(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a nodeNotFoundError error, got %v", err)
}
} }
func TestNodeInspectWithEmptyID(t *testing.T) { func TestNodeInspectWithEmptyID(t *testing.T) {
@ -44,9 +42,7 @@ func TestNodeInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.NodeInspectWithRaw(context.Background(), "") _, _, err := client.NodeInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestNodeInspect(t *testing.T) { func TestNodeInspect(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNodeListError(t *testing.T) { func TestNodeListError(t *testing.T) {
@ -22,9 +24,7 @@ func TestNodeListError(t *testing.T) {
} }
_, err := client.NodeList(context.Background(), types.NodeListOptions{}) _, err := client.NodeList(context.Background(), types.NodeListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNodeList(t *testing.T) { func TestNodeList(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNodeRemoveError(t *testing.T) { func TestNodeRemoveError(t *testing.T) {
@ -19,9 +21,7 @@ func TestNodeRemoveError(t *testing.T) {
} }
err := client.NodeRemove(context.Background(), "node_id", types.NodeRemoveOptions{Force: false}) err := client.NodeRemove(context.Background(), "node_id", types.NodeRemoveOptions{Force: false})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNodeRemove(t *testing.T) { func TestNodeRemove(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestNodeUpdateError(t *testing.T) { func TestNodeUpdateError(t *testing.T) {
@ -19,9 +21,7 @@ func TestNodeUpdateError(t *testing.T) {
} }
err := client.NodeUpdate(context.Background(), "node_id", swarm.Version{}, swarm.NodeSpec{}) err := client.NodeUpdate(context.Background(), "node_id", swarm.Version{}, swarm.NodeSpec{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestNodeUpdate(t *testing.T) { func TestNodeUpdate(t *testing.T) {

View file

@ -34,7 +34,7 @@ func TestPingFail(t *testing.T) {
} }
ping, err := client.Ping(context.Background()) ping, err := client.Ping(context.Background())
assert.ErrorContains(t, err, "some error with the server") assert.Check(t, is.ErrorContains(err, "some error with the server"))
assert.Check(t, is.Equal(false, ping.Experimental)) assert.Check(t, is.Equal(false, ping.Experimental))
assert.Check(t, is.Equal("", ping.APIVersion)) assert.Check(t, is.Equal("", ping.APIVersion))
var si *swarm.Status var si *swarm.Status
@ -42,7 +42,7 @@ func TestPingFail(t *testing.T) {
withHeader = true withHeader = true
ping2, err := client.Ping(context.Background()) ping2, err := client.Ping(context.Background())
assert.ErrorContains(t, err, "some error with the server") assert.Check(t, is.ErrorContains(err, "some error with the server"))
assert.Check(t, is.Equal(true, ping2.Experimental)) assert.Check(t, is.Equal(true, ping2.Experimental))
assert.Check(t, is.Equal("awesome", ping2.APIVersion)) assert.Check(t, is.Equal("awesome", ping2.APIVersion))
assert.Check(t, is.Equal(swarm.Status{NodeState: "inactive"}, *ping2.SwarmStatus)) assert.Check(t, is.Equal(swarm.Status{NodeState: "inactive"}, *ping2.SwarmStatus))
@ -64,7 +64,7 @@ func TestPingWithError(t *testing.T) {
} }
ping, err := client.Ping(context.Background()) ping, err := client.Ping(context.Background())
assert.ErrorContains(t, err, "some error") assert.Check(t, is.ErrorContains(err, "some error"))
assert.Check(t, is.Equal(false, ping.Experimental)) assert.Check(t, is.Equal(false, ping.Experimental))
assert.Check(t, is.Equal("", ping.APIVersion)) assert.Check(t, is.Equal("", ping.APIVersion))
var si *swarm.Status var si *swarm.Status

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginDisableError(t *testing.T) { func TestPluginDisableError(t *testing.T) {
@ -19,9 +21,7 @@ func TestPluginDisableError(t *testing.T) {
} }
err := client.PluginDisable(context.Background(), "plugin_name", types.PluginDisableOptions{}) err := client.PluginDisable(context.Background(), "plugin_name", types.PluginDisableOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginDisable(t *testing.T) { func TestPluginDisable(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginEnableError(t *testing.T) { func TestPluginEnableError(t *testing.T) {
@ -19,9 +21,7 @@ func TestPluginEnableError(t *testing.T) {
} }
err := client.PluginEnable(context.Background(), "plugin_name", types.PluginEnableOptions{}) err := client.PluginEnable(context.Background(), "plugin_name", types.PluginEnableOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginEnable(t *testing.T) { func TestPluginEnable(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginInspectError(t *testing.T) { func TestPluginInspectError(t *testing.T) {
@ -21,9 +23,7 @@ func TestPluginInspectError(t *testing.T) {
} }
_, _, err := client.PluginInspectWithRaw(context.Background(), "nothing") _, _, err := client.PluginInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginInspectWithEmptyID(t *testing.T) { func TestPluginInspectWithEmptyID(t *testing.T) {
@ -33,9 +33,7 @@ func TestPluginInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.PluginInspectWithRaw(context.Background(), "") _, _, err := client.PluginInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestPluginInspect(t *testing.T) { func TestPluginInspect(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginListError(t *testing.T) { func TestPluginListError(t *testing.T) {
@ -21,9 +23,7 @@ func TestPluginListError(t *testing.T) {
} }
_, err := client.PluginList(context.Background(), filters.NewArgs()) _, err := client.PluginList(context.Background(), filters.NewArgs())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginList(t *testing.T) { func TestPluginList(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginPushError(t *testing.T) { func TestPluginPushError(t *testing.T) {
@ -19,9 +21,7 @@ func TestPluginPushError(t *testing.T) {
} }
_, err := client.PluginPush(context.Background(), "plugin_name", "") _, err := client.PluginPush(context.Background(), "plugin_name", "")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginPush(t *testing.T) { func TestPluginPush(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginRemoveError(t *testing.T) { func TestPluginRemoveError(t *testing.T) {
@ -19,9 +21,7 @@ func TestPluginRemoveError(t *testing.T) {
} }
err := client.PluginRemove(context.Background(), "plugin_name", types.PluginRemoveOptions{}) err := client.PluginRemove(context.Background(), "plugin_name", types.PluginRemoveOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginRemove(t *testing.T) { func TestPluginRemove(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestPluginSetError(t *testing.T) { func TestPluginSetError(t *testing.T) {
@ -18,9 +20,7 @@ func TestPluginSetError(t *testing.T) {
} }
err := client.PluginSet(context.Background(), "plugin_name", []string{}) err := client.PluginSet(context.Background(), "plugin_name", []string{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestPluginSet(t *testing.T) { func TestPluginSet(t *testing.T) {

View file

@ -88,9 +88,7 @@ func TestPlainTextError(t *testing.T) {
client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ContainerList(context.Background(), types.ContainerListOptions{}) _, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestInfiniteError(t *testing.T) { func TestInfiniteError(t *testing.T) {

View file

@ -32,9 +32,7 @@ func TestSecretCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.SecretCreate(context.Background(), swarm.SecretSpec{}) _, err := client.SecretCreate(context.Background(), swarm.SecretSpec{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSecretCreate(t *testing.T) { func TestSecretCreate(t *testing.T) {

View file

@ -33,9 +33,7 @@ func TestSecretInspectError(t *testing.T) {
} }
_, _, err := client.SecretInspectWithRaw(context.Background(), "nothing") _, _, err := client.SecretInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSecretInspectSecretNotFound(t *testing.T) { func TestSecretInspectSecretNotFound(t *testing.T) {
@ -45,9 +43,7 @@ func TestSecretInspectSecretNotFound(t *testing.T) {
} }
_, _, err := client.SecretInspectWithRaw(context.Background(), "unknown") _, _, err := client.SecretInspectWithRaw(context.Background(), "unknown")
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a secretNotFoundError error, got %v", err)
}
} }
func TestSecretInspectWithEmptyID(t *testing.T) { func TestSecretInspectWithEmptyID(t *testing.T) {
@ -57,9 +53,7 @@ func TestSecretInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.SecretInspectWithRaw(context.Background(), "") _, _, err := client.SecretInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestSecretInspect(t *testing.T) { func TestSecretInspect(t *testing.T) {

View file

@ -34,9 +34,7 @@ func TestSecretListError(t *testing.T) {
} }
_, err := client.SecretList(context.Background(), types.SecretListOptions{}) _, err := client.SecretList(context.Background(), types.SecretListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSecretList(t *testing.T) { func TestSecretList(t *testing.T) {

View file

@ -30,9 +30,7 @@ func TestSecretRemoveError(t *testing.T) {
} }
err := client.SecretRemove(context.Background(), "secret_id") err := client.SecretRemove(context.Background(), "secret_id")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSecretRemove(t *testing.T) { func TestSecretRemove(t *testing.T) {

View file

@ -31,9 +31,7 @@ func TestSecretUpdateError(t *testing.T) {
} }
err := client.SecretUpdate(context.Background(), "secret_id", swarm.Version{}, swarm.SecretSpec{}) err := client.SecretUpdate(context.Background(), "secret_id", swarm.Version{}, swarm.SecretSpec{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSecretUpdate(t *testing.T) { func TestSecretUpdate(t *testing.T) {

View file

@ -25,9 +25,7 @@ func TestServiceCreateError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{}) _, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestServiceCreate(t *testing.T) { func TestServiceCreate(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestServiceInspectError(t *testing.T) { func TestServiceInspectError(t *testing.T) {
@ -22,9 +24,7 @@ func TestServiceInspectError(t *testing.T) {
} }
_, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", types.ServiceInspectOptions{}) _, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", types.ServiceInspectOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestServiceInspectServiceNotFound(t *testing.T) { func TestServiceInspectServiceNotFound(t *testing.T) {
@ -33,9 +33,7 @@ func TestServiceInspectServiceNotFound(t *testing.T) {
} }
_, _, err := client.ServiceInspectWithRaw(context.Background(), "unknown", types.ServiceInspectOptions{}) _, _, err := client.ServiceInspectWithRaw(context.Background(), "unknown", types.ServiceInspectOptions{})
if err == nil || !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("expected a serviceNotFoundError error, got %v", err)
}
} }
func TestServiceInspectWithEmptyID(t *testing.T) { func TestServiceInspectWithEmptyID(t *testing.T) {
@ -45,9 +43,7 @@ func TestServiceInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.ServiceInspectWithRaw(context.Background(), "", types.ServiceInspectOptions{}) _, _, err := client.ServiceInspectWithRaw(context.Background(), "", types.ServiceInspectOptions{})
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestServiceInspect(t *testing.T) { func TestServiceInspect(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestServiceListError(t *testing.T) { func TestServiceListError(t *testing.T) {
@ -22,9 +24,7 @@ func TestServiceListError(t *testing.T) {
} }
_, err := client.ServiceList(context.Background(), types.ServiceListOptions{}) _, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestServiceList(t *testing.T) { func TestServiceList(t *testing.T) {

View file

@ -23,9 +23,8 @@ func TestServiceLogsError(t *testing.T) {
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
} }
_, err := client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{}) _, err := client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
_, err = client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{ _, err = client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{
Since: "2006-01-02TZ", Since: "2006-01-02TZ",
}) })

View file

@ -11,6 +11,7 @@ import (
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestServiceRemoveError(t *testing.T) { func TestServiceRemoveError(t *testing.T) {
@ -19,9 +20,7 @@ func TestServiceRemoveError(t *testing.T) {
} }
err := client.ServiceRemove(context.Background(), "service_id") err := client.ServiceRemove(context.Background(), "service_id")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestServiceRemoveNotFoundError(t *testing.T) { func TestServiceRemoveNotFoundError(t *testing.T) {
@ -30,8 +29,8 @@ func TestServiceRemoveNotFoundError(t *testing.T) {
} }
err := client.ServiceRemove(context.Background(), "service_id") err := client.ServiceRemove(context.Background(), "service_id")
assert.ErrorContains(t, err, "no such service: service_id") assert.Check(t, is.ErrorContains(err, "no such service: service_id"))
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
} }
func TestServiceRemove(t *testing.T) { func TestServiceRemove(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestServiceUpdateError(t *testing.T) { func TestServiceUpdateError(t *testing.T) {
@ -20,9 +22,7 @@ func TestServiceUpdateError(t *testing.T) {
} }
_, err := client.ServiceUpdate(context.Background(), "service_id", swarm.Version{}, swarm.ServiceSpec{}, types.ServiceUpdateOptions{}) _, err := client.ServiceUpdate(context.Background(), "service_id", swarm.Version{}, swarm.ServiceSpec{}, types.ServiceUpdateOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestServiceUpdate(t *testing.T) { func TestServiceUpdate(t *testing.T) {

View file

@ -22,9 +22,7 @@ func TestSwarmGetUnlockKeyError(t *testing.T) {
} }
_, err := client.SwarmGetUnlockKey(context.Background()) _, err := client.SwarmGetUnlockKey(context.Background())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmGetUnlockKey(t *testing.T) { func TestSwarmGetUnlockKey(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmInitError(t *testing.T) { func TestSwarmInitError(t *testing.T) {
@ -19,9 +21,7 @@ func TestSwarmInitError(t *testing.T) {
} }
_, err := client.SwarmInit(context.Background(), swarm.InitRequest{}) _, err := client.SwarmInit(context.Background(), swarm.InitRequest{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmInit(t *testing.T) { func TestSwarmInit(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmInspectError(t *testing.T) { func TestSwarmInspectError(t *testing.T) {
@ -20,9 +22,7 @@ func TestSwarmInspectError(t *testing.T) {
} }
_, err := client.SwarmInspect(context.Background()) _, err := client.SwarmInspect(context.Background())
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmInspect(t *testing.T) { func TestSwarmInspect(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmJoinError(t *testing.T) { func TestSwarmJoinError(t *testing.T) {
@ -19,9 +21,7 @@ func TestSwarmJoinError(t *testing.T) {
} }
err := client.SwarmJoin(context.Background(), swarm.JoinRequest{}) err := client.SwarmJoin(context.Background(), swarm.JoinRequest{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmJoin(t *testing.T) { func TestSwarmJoin(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmLeaveError(t *testing.T) { func TestSwarmLeaveError(t *testing.T) {
@ -18,9 +20,7 @@ func TestSwarmLeaveError(t *testing.T) {
} }
err := client.SwarmLeave(context.Background(), false) err := client.SwarmLeave(context.Background(), false)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmLeave(t *testing.T) { func TestSwarmLeave(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmUnlockError(t *testing.T) { func TestSwarmUnlockError(t *testing.T) {
@ -19,9 +21,7 @@ func TestSwarmUnlockError(t *testing.T) {
} }
err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{UnlockKey: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"}) err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{UnlockKey: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmUnlock(t *testing.T) { func TestSwarmUnlock(t *testing.T) {

View file

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestSwarmUpdateError(t *testing.T) { func TestSwarmUpdateError(t *testing.T) {
@ -19,9 +21,7 @@ func TestSwarmUpdateError(t *testing.T) {
} }
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, swarm.UpdateFlags{}) err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, swarm.UpdateFlags{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestSwarmUpdate(t *testing.T) { func TestSwarmUpdate(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/pkg/errors" "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestTaskInspectError(t *testing.T) { func TestTaskInspectError(t *testing.T) {
@ -21,9 +23,7 @@ func TestTaskInspectError(t *testing.T) {
} }
_, _, err := client.TaskInspectWithRaw(context.Background(), "nothing") _, _, err := client.TaskInspectWithRaw(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestTaskInspectWithEmptyID(t *testing.T) { func TestTaskInspectWithEmptyID(t *testing.T) {
@ -33,9 +33,7 @@ func TestTaskInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.TaskInspectWithRaw(context.Background(), "") _, _, err := client.TaskInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestTaskInspect(t *testing.T) { func TestTaskInspect(t *testing.T) {

View file

@ -14,6 +14,8 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestTaskListError(t *testing.T) { func TestTaskListError(t *testing.T) {
@ -22,9 +24,7 @@ func TestTaskListError(t *testing.T) {
} }
_, err := client.TaskList(context.Background(), types.TaskListOptions{}) _, err := client.TaskList(context.Background(), types.TaskListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestTaskList(t *testing.T) { func TestTaskList(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestVolumeCreateError(t *testing.T) { func TestVolumeCreateError(t *testing.T) {
@ -20,9 +22,7 @@ func TestVolumeCreateError(t *testing.T) {
} }
_, err := client.VolumeCreate(context.Background(), volume.CreateOptions{}) _, err := client.VolumeCreate(context.Background(), volume.CreateOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestVolumeCreate(t *testing.T) { func TestVolumeCreate(t *testing.T) {

View file

@ -23,9 +23,7 @@ func TestVolumeInspectError(t *testing.T) {
} }
_, err := client.VolumeInspect(context.Background(), "nothing") _, err := client.VolumeInspect(context.Background(), "nothing")
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestVolumeInspectNotFound(t *testing.T) { func TestVolumeInspectNotFound(t *testing.T) {
@ -34,7 +32,7 @@ func TestVolumeInspectNotFound(t *testing.T) {
} }
_, err := client.VolumeInspect(context.Background(), "unknown") _, err := client.VolumeInspect(context.Background(), "unknown")
assert.Check(t, IsErrNotFound(err)) assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
} }
func TestVolumeInspectWithEmptyID(t *testing.T) { func TestVolumeInspectWithEmptyID(t *testing.T) {
@ -44,9 +42,7 @@ func TestVolumeInspectWithEmptyID(t *testing.T) {
}), }),
} }
_, _, err := client.VolumeInspectWithRaw(context.Background(), "") _, _, err := client.VolumeInspectWithRaw(context.Background(), "")
if !IsErrNotFound(err) { assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
t.Fatalf("Expected NotFoundError, got %v", err)
}
} }
func TestVolumeInspect(t *testing.T) { func TestVolumeInspect(t *testing.T) {

View file

@ -13,6 +13,8 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestVolumeListError(t *testing.T) { func TestVolumeListError(t *testing.T) {
@ -21,9 +23,7 @@ func TestVolumeListError(t *testing.T) {
} }
_, err := client.VolumeList(context.Background(), volume.ListOptions{}) _, err := client.VolumeList(context.Background(), volume.ListOptions{})
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestVolumeList(t *testing.T) { func TestVolumeList(t *testing.T) {

View file

@ -10,6 +10,8 @@ import (
"testing" "testing"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestVolumeRemoveError(t *testing.T) { func TestVolumeRemoveError(t *testing.T) {
@ -18,9 +20,7 @@ func TestVolumeRemoveError(t *testing.T) {
} }
err := client.VolumeRemove(context.Background(), "volume_id", false) err := client.VolumeRemove(context.Background(), "volume_id", false)
if !errdefs.IsSystem(err) { assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestVolumeRemove(t *testing.T) { func TestVolumeRemove(t *testing.T) {

View file

@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
volumetypes "github.com/docker/docker/api/types/volume" volumetypes "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
) )
func TestVolumeUpdateError(t *testing.T) { func TestVolumeUpdateError(t *testing.T) {
@ -20,10 +22,7 @@ func TestVolumeUpdateError(t *testing.T) {
} }
err := client.VolumeUpdate(context.Background(), "", swarm.Version{}, volumetypes.UpdateOptions{}) err := client.VolumeUpdate(context.Background(), "", swarm.Version{}, volumetypes.UpdateOptions{})
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
if !errdefs.IsSystem(err) {
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
}
} }
func TestVolumeUpdate(t *testing.T) { func TestVolumeUpdate(t *testing.T) {