Merge pull request #40080 from thaJeztah/client_string_matching
client: reduce string-matching in tests
This commit is contained in:
commit
0a96ee7ff8
91 changed files with 139 additions and 371 deletions
|
@ -23,11 +23,8 @@ func TestCheckpointCreateError(t *testing.T) {
|
|||
Exit: true,
|
||||
})
|
||||
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestCheckpointDeleteError(t *testing.T) {
|
|||
CheckpointID: "checkpoint_id",
|
||||
})
|
||||
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestCheckpointListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.CheckpointList(context.Background(), "container_id", types.CheckpointListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,8 @@ func TestConfigCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ConfigCreate(context.Background(), swarm.ConfigSpec{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,8 @@ func TestConfigInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.ConfigInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,8 @@ func TestConfigListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ConfigList(context.Background(), types.ConfigListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,8 @@ func TestConfigRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.ConfigRemove(context.Background(), "config_id")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,8 @@ func TestConfigUpdateError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.ConfigUpdate(context.Background(), "config_id", swarm.Version{}, swarm.ConfigSpec{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerCommitError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerCommit(context.Background(), "nothing", types.ContainerCommitOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestContainerStatPathError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerStatPath(context.Background(), "container_id", "path")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,11 +100,8 @@ func TestCopyToContainerError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.CopyToContainer(context.Background(), "container_id", "path/to/file", bytes.NewReader([]byte("")), types.CopyToContainerOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,11 +177,8 @@ func TestCopyFromContainerError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, _, err := client.CopyFromContainer(context.Background(), "container_id", "path/to/file")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@ func TestContainerCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerCreate(context.Background(), nil, nil, nil, "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error while testing StatusInternalServerError, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error while testing StatusInternalServerError, got %T", err)
|
||||
}
|
||||
|
@ -31,9 +28,6 @@ func TestContainerCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusNotFound, "Server error")),
|
||||
}
|
||||
_, err = client.ContainerCreate(context.Background(), nil, nil, nil, "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error while testing StatusNotFound, got %v", err)
|
||||
}
|
||||
if err == nil || !IsErrNotFound(err) {
|
||||
t.Fatalf("expected a Server Error while testing StatusNotFound, got %T", err)
|
||||
}
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerDiffError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerDiff(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerExecCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerExecCreate(context.Background(), "container_id", types.ExecConfig{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,11 +74,8 @@ func TestContainerExecStartError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerExecStart(context.Background(), "nothing", types.ExecStartCheck{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,11 +118,8 @@ func TestContainerExecInspectError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerExecInspect(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerExportError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerExport(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestContainerInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ContainerInspect(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerKillError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerKill(context.Background(), "nothing", "SIGKILL")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestContainerListError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -33,7 +34,9 @@ func TestContainerLogsError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
_, err = client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{
|
||||
Since: "2006-01-02TZ",
|
||||
})
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerPauseError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerPause(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -25,7 +26,9 @@ func TestContainersPruneError(t *testing.T) {
|
|||
filters := filters.NewArgs()
|
||||
|
||||
_, err := client.ContainersPrune(context.Background(), filters)
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainersPrune(t *testing.T) {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -19,7 +20,9 @@ func TestContainerRemoveError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerRemove(context.Background(), "container_id", types.ContainerRemoveOptions{})
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerRemoveNotFoundError(t *testing.T) {
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerRenameError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerRename(context.Background(), "nothing", "newNothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestContainerResizeError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,11 +28,8 @@ func TestContainerExecResizeError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerRestartError(t *testing.T) {
|
|||
}
|
||||
timeout := 0 * time.Second
|
||||
err := client.ContainerRestart(context.Background(), "nothing", &timeout)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerStartError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerStart(context.Background(), "nothing", types.ContainerStartOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerStatsError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerStats(context.Background(), "nothing", false)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerStopError(t *testing.T) {
|
|||
}
|
||||
timeout := 0 * time.Second
|
||||
err := client.ContainerStop(context.Background(), "nothing", &timeout)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestContainerTopError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerTop(context.Background(), "nothing", []string{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,8 @@ func TestContainerUnpauseError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerUnpause(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestContainerUpdateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerUpdate(context.Background(), "nothing", container.UpdateConfig{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,8 @@ func TestContainerWaitError(t *testing.T) {
|
|||
case result := <-resultC:
|
||||
t.Fatalf("expected to not get a wait result, got %d", result.StatusCode)
|
||||
case err := <-errC:
|
||||
if err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestDiskUsageError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.DiskUsage(context.Background())
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,11 +53,8 @@ func TestEventsErrorFromServer(t *testing.T) {
|
|||
}
|
||||
_, errs := client.Events(context.Background(), types.EventsOptions{})
|
||||
err := <-errs
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestImageBuildError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageBuild(context.Background(), nil, types.ImageBuildOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestImageCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageCreate(context.Background(), "reference", types.ImageCreateOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestImageHistoryError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageHistory(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestImageImportError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageImport(context.Background(), types.ImageImportSource{}, "image:tag", types.ImageImportOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestImageInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.ImageInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestImageListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ImageList(context.Background(), types.ImageListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestImageLoadError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ImageLoad(context.Background(), nil, true)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/errdefs"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"gotest.tools/assert"
|
||||
|
@ -22,10 +24,10 @@ func TestImagesPruneError(t *testing.T) {
|
|||
version: "1.25",
|
||||
}
|
||||
|
||||
filters := filters.NewArgs()
|
||||
|
||||
_, err := client.ImagesPrune(context.Background(), filters)
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
_, err := client.ImagesPrune(context.Background(), filters.NewArgs())
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImagesPrune(t *testing.T) {
|
||||
|
|
|
@ -31,11 +31,8 @@ func TestImagePullAnyError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,8 +41,8 @@ func TestImagePullStatusUnauthorizedError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
|
||||
}
|
||||
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +71,8 @@ func TestImagePullWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
|
|||
_, err := client.ImagePull(context.Background(), "myimage", types.ImagePullOptions{
|
||||
PrivilegeFunc: privilegeFunc,
|
||||
})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,8 @@ func TestImagePushAnyError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,8 +46,8 @@ func TestImagePushStatusUnauthorizedError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
|
||||
}
|
||||
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,8 +76,8 @@ func TestImagePushWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.T)
|
|||
_, err := client.ImagePush(context.Background(), "myimage", types.ImagePushOptions{
|
||||
PrivilegeFunc: privilegeFunc,
|
||||
})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -21,7 +22,9 @@ func TestImageRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ImageRemove(context.Background(), "image_id", types.ImageRemoveOptions{})
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageRemoveImageNotFound(t *testing.T) {
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestImageSaveError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageSave(context.Background(), []string{"nothing"})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestImageSearchAnyError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +31,8 @@ func TestImageSearchStatusUnauthorizedError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
|
||||
}
|
||||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,8 +61,8 @@ func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.
|
|||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{
|
||||
PrivilegeFunc: privilegeFunc,
|
||||
})
|
||||
if err == nil || err.Error() != "Error response from daemon: Unauthorized error" {
|
||||
t.Fatalf("expected an Unauthorized Error, got %v", err)
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestImageTagError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.ImageTag(context.Background(), "image_id", "repo:tag")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestInfoServerError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.Info(context.Background())
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestNetworkConnectError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.NetworkConnect(context.Background(), "network_id", "container_id", nil)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestNetworkCreateError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.NetworkCreate(context.Background(), "mynetwork", types.NetworkCreate{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestNetworkDisconnectError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.NetworkDisconnect(context.Background(), "network_id", "container_id", false)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
|
@ -23,7 +24,9 @@ func TestNetworkInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.NetworkInspect(context.Background(), "nothing", types.NetworkInspectOptions{})
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNetworkInspectNotFoundError(t *testing.T) {
|
||||
|
|
|
@ -23,11 +23,8 @@ func TestNetworkListError(t *testing.T) {
|
|||
_, err := client.NetworkList(context.Background(), types.NetworkListOptions{
|
||||
Filters: filters.NewArgs(),
|
||||
})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,8 @@ func TestNetworksPruneError(t *testing.T) {
|
|||
filters := filters.NewArgs()
|
||||
|
||||
_, err := client.NetworksPrune(context.Background(), filters)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestNetworkRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.NetworkRemove(context.Background(), "network_id")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestNodeInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.NodeInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestNodeListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.NodeList(context.Background(), types.NodeListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestNodeRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.NodeRemove(context.Background(), "node_id", types.NodeRemoveOptions{Force: false})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestNodeUpdateError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.NodeUpdate(context.Background(), "node_id", swarm.Version{}, swarm.NodeSpec{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestPluginDisableError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.PluginDisable(context.Background(), "plugin_name", types.PluginDisableOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestPluginEnableError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.PluginEnable(context.Background(), "plugin_name", types.PluginEnableOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestPluginInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.PluginInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestPluginListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.PluginList(context.Background(), filters.NewArgs())
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestPluginPushError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.PluginPush(context.Background(), "plugin_name", "")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestPluginRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.PluginRemove(context.Background(), "plugin_name", types.PluginRemoveOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestPluginSetError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.PluginSet(context.Background(), "plugin_name", []string{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -86,11 +86,8 @@ func TestPlainTextError(t *testing.T) {
|
|||
client: newMockClient(plainTextErrorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,8 @@ func TestSecretCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.SecretCreate(context.Background(), swarm.SecretSpec{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,8 @@ func TestSecretInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.SecretInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,8 @@ func TestSecretListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.SecretList(context.Background(), types.SecretListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,8 @@ func TestSecretRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SecretRemove(context.Background(), "secret_id")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,8 @@ func TestSecretUpdateError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SecretUpdate(context.Background(), "secret_id", swarm.Version{}, swarm.SecretSpec{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,8 @@ func TestServiceCreateError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestServiceInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", types.ServiceInspectOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestServiceListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ServiceList(context.Background(), types.ServiceListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -23,7 +24,9 @@ func TestServiceLogsError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{})
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
_, err = client.ServiceLogs(context.Background(), "service_id", types.ContainerLogsOptions{
|
||||
Since: "2006-01-02TZ",
|
||||
})
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -19,7 +20,9 @@ func TestServiceRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.ServiceRemove(context.Background(), "service_id")
|
||||
assert.Check(t, is.Error(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceRemoveNotFoundError(t *testing.T) {
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestServiceUpdateError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.ServiceUpdate(context.Background(), "service_id", swarm.Version{}, swarm.ServiceSpec{}, types.ServiceUpdateOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
)
|
||||
|
@ -21,7 +22,9 @@ func TestSwarmGetUnlockKeyError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.SwarmGetUnlockKey(context.Background())
|
||||
assert.Check(t, is.ErrorContains(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwarmGetUnlockKey(t *testing.T) {
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestSwarmInitError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.SwarmInit(context.Background(), swarm.InitRequest{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,8 @@ func TestSwarmInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.SwarmInspect(context.Background())
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestSwarmJoinError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SwarmJoin(context.Background(), swarm.JoinRequest{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestSwarmLeaveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SwarmLeave(context.Background(), false)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestSwarmUnlockError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{UnlockKey: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,8 @@ func TestSwarmUpdateError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, swarm.UpdateFlags{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestTaskInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, _, err := client.TaskInspectWithRaw(context.Background(), "nothing")
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestTaskListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.TaskList(context.Background(), types.TaskListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ func TestVolumeCreateError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.VolumeCreate(context.Background(), volumetypes.VolumeCreateBody{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/assert"
|
||||
is "gotest.tools/assert/cmp"
|
||||
|
@ -22,7 +23,9 @@ func TestVolumeInspectError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.VolumeInspect(context.Background(), "nothing")
|
||||
assert.Check(t, is.ErrorContains(err, "Error response from daemon: Server error"))
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVolumeInspectNotFound(t *testing.T) {
|
||||
|
|
|
@ -22,11 +22,8 @@ func TestVolumeListError(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err := client.VolumeList(context.Background(), filters.NewArgs())
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ func TestVolumeRemoveError(t *testing.T) {
|
|||
}
|
||||
|
||||
err := client.VolumeRemove(context.Background(), "volume_id", false)
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %T", err)
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue