Browse code

client/service: use containerd errdefs checks

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2025/05/19 21:14:16
Showing 6 changed files
... ...
@@ -10,9 +10,9 @@ import (
10 10
 	"strings"
11 11
 	"testing"
12 12
 
13
+	cerrdefs "github.com/containerd/errdefs"
13 14
 	registrytypes "github.com/docker/docker/api/types/registry"
14 15
 	"github.com/docker/docker/api/types/swarm"
15
-	"github.com/docker/docker/errdefs"
16 16
 	"github.com/opencontainers/go-digest"
17 17
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
18 18
 	"gotest.tools/v3/assert"
... ...
@@ -24,7 +24,7 @@ func TestServiceCreateError(t *testing.T) {
24 24
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
25 25
 	}
26 26
 	_, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, swarm.ServiceCreateOptions{})
27
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
27
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
28 28
 }
29 29
 
30 30
 // TestServiceCreateConnectionError verifies that connection errors occurring
... ...
@@ -11,8 +11,8 @@ import (
11 11
 	"strings"
12 12
 	"testing"
13 13
 
14
+	cerrdefs "github.com/containerd/errdefs"
14 15
 	"github.com/docker/docker/api/types/swarm"
15
-	"github.com/docker/docker/errdefs"
16 16
 	"gotest.tools/v3/assert"
17 17
 	is "gotest.tools/v3/assert/cmp"
18 18
 )
... ...
@@ -23,7 +23,7 @@ func TestServiceInspectError(t *testing.T) {
23 23
 	}
24 24
 
25 25
 	_, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", swarm.ServiceInspectOptions{})
26
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
26
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
27 27
 }
28 28
 
29 29
 func TestServiceInspectServiceNotFound(t *testing.T) {
... ...
@@ -32,7 +32,7 @@ func TestServiceInspectServiceNotFound(t *testing.T) {
32 32
 	}
33 33
 
34 34
 	_, _, err := client.ServiceInspectWithRaw(context.Background(), "unknown", swarm.ServiceInspectOptions{})
35
-	assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
35
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
36 36
 }
37 37
 
38 38
 func TestServiceInspectWithEmptyID(t *testing.T) {
... ...
@@ -42,11 +42,11 @@ func TestServiceInspectWithEmptyID(t *testing.T) {
42 42
 		}),
43 43
 	}
44 44
 	_, _, err := client.ServiceInspectWithRaw(context.Background(), "", swarm.ServiceInspectOptions{})
45
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
45
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
46 46
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
47 47
 
48 48
 	_, _, err = client.ServiceInspectWithRaw(context.Background(), "    ", swarm.ServiceInspectOptions{})
49
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
49
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
50 50
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
51 51
 }
52 52
 
... ...
@@ -10,9 +10,9 @@ import (
10 10
 	"strings"
11 11
 	"testing"
12 12
 
13
+	cerrdefs "github.com/containerd/errdefs"
13 14
 	"github.com/docker/docker/api/types/filters"
14 15
 	"github.com/docker/docker/api/types/swarm"
15
-	"github.com/docker/docker/errdefs"
16 16
 	"gotest.tools/v3/assert"
17 17
 	is "gotest.tools/v3/assert/cmp"
18 18
 )
... ...
@@ -23,7 +23,7 @@ func TestServiceListError(t *testing.T) {
23 23
 	}
24 24
 
25 25
 	_, err := client.ServiceList(context.Background(), swarm.ServiceListOptions{})
26
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
26
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
27 27
 }
28 28
 
29 29
 func TestServiceList(t *testing.T) {
... ...
@@ -12,8 +12,8 @@ import (
12 12
 	"testing"
13 13
 	"time"
14 14
 
15
+	cerrdefs "github.com/containerd/errdefs"
15 16
 	"github.com/docker/docker/api/types/container"
16
-	"github.com/docker/docker/errdefs"
17 17
 	"gotest.tools/v3/assert"
18 18
 	is "gotest.tools/v3/assert/cmp"
19 19
 )
... ...
@@ -23,7 +23,7 @@ func TestServiceLogsError(t *testing.T) {
23 23
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
24 24
 	}
25 25
 	_, err := client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{})
26
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
26
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
27 27
 
28 28
 	_, err = client.ServiceLogs(context.Background(), "service_id", container.LogsOptions{
29 29
 		Since: "2006-01-02TZ",
... ...
@@ -31,11 +31,11 @@ func TestServiceLogsError(t *testing.T) {
31 31
 	assert.Check(t, is.ErrorContains(err, `parsing time "2006-01-02TZ"`))
32 32
 
33 33
 	_, err = client.ServiceLogs(context.Background(), "", container.LogsOptions{})
34
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
34
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
35 35
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
36 36
 
37 37
 	_, err = client.ServiceLogs(context.Background(), "    ", container.LogsOptions{})
38
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
38
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
39 39
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
40 40
 }
41 41
 
... ...
@@ -9,7 +9,7 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
-	"github.com/docker/docker/errdefs"
12
+	cerrdefs "github.com/containerd/errdefs"
13 13
 	"gotest.tools/v3/assert"
14 14
 	is "gotest.tools/v3/assert/cmp"
15 15
 )
... ...
@@ -20,14 +20,14 @@ func TestServiceRemoveError(t *testing.T) {
20 20
 	}
21 21
 
22 22
 	err := client.ServiceRemove(context.Background(), "service_id")
23
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
23
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
24 24
 
25 25
 	err = client.ServiceRemove(context.Background(), "")
26
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
26
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
27 27
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
28 28
 
29 29
 	err = client.ServiceRemove(context.Background(), "    ")
30
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
30
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
31 31
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
32 32
 }
33 33
 
... ...
@@ -38,7 +38,7 @@ func TestServiceRemoveNotFoundError(t *testing.T) {
38 38
 
39 39
 	err := client.ServiceRemove(context.Background(), "service_id")
40 40
 	assert.Check(t, is.ErrorContains(err, "no such service: service_id"))
41
-	assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
41
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
42 42
 }
43 43
 
44 44
 func TestServiceRemove(t *testing.T) {
... ...
@@ -9,8 +9,8 @@ import (
9 9
 	"strings"
10 10
 	"testing"
11 11
 
12
+	cerrdefs "github.com/containerd/errdefs"
12 13
 	"github.com/docker/docker/api/types/swarm"
13
-	"github.com/docker/docker/errdefs"
14 14
 	"gotest.tools/v3/assert"
15 15
 	is "gotest.tools/v3/assert/cmp"
16 16
 )
... ...
@@ -21,14 +21,14 @@ func TestServiceUpdateError(t *testing.T) {
21 21
 	}
22 22
 
23 23
 	_, err := client.ServiceUpdate(context.Background(), "service_id", swarm.Version{}, swarm.ServiceSpec{}, swarm.ServiceUpdateOptions{})
24
-	assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
24
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
25 25
 
26 26
 	_, err = client.ServiceUpdate(context.Background(), "", swarm.Version{}, swarm.ServiceSpec{}, swarm.ServiceUpdateOptions{})
27
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
27
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
28 28
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
29 29
 
30 30
 	_, err = client.ServiceUpdate(context.Background(), "    ", swarm.Version{}, swarm.ServiceSpec{}, swarm.ServiceUpdateOptions{})
31
-	assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
31
+	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
32 32
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
33 33
 }
34 34