mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client/secret: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
df96159df0
commit
ad4a3d32c6
@@ -10,8 +10,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@@ -31,7 +31,7 @@ func TestSecretCreateError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.SecretCreate(context.Background(), swarm.SecretSpec{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestSecretCreate(t *testing.T) {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@@ -33,7 +33,7 @@ func TestSecretInspectError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, _, err := client.SecretInspectWithRaw(context.Background(), "nothing")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestSecretInspectSecretNotFound(t *testing.T) {
|
||||
@@ -43,7 +43,7 @@ func TestSecretInspectSecretNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
_, _, err := client.SecretInspectWithRaw(context.Background(), "unknown")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
|
||||
}
|
||||
|
||||
func TestSecretInspectWithEmptyID(t *testing.T) {
|
||||
@@ -53,11 +53,11 @@ func TestSecretInspectWithEmptyID(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
_, _, err := client.SecretInspectWithRaw(context.Background(), "")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
|
||||
_, _, err = client.SecretInspectWithRaw(context.Background(), " ")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@@ -33,7 +33,7 @@ func TestSecretListError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := client.SecretList(context.Background(), swarm.SecretListOptions{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
func TestSecretList(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/errdefs"
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@@ -30,14 +30,14 @@ func TestSecretRemoveError(t *testing.T) {
|
||||
}
|
||||
|
||||
err := client.SecretRemove(context.Background(), "secret_id")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
|
||||
err = client.SecretRemove(context.Background(), "")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
|
||||
err = client.SecretRemove(context.Background(), " ")
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
cerrdefs "github.com/containerd/errdefs"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@@ -31,14 +31,14 @@ func TestSecretUpdateError(t *testing.T) {
|
||||
}
|
||||
|
||||
err := client.SecretUpdate(context.Background(), "secret_id", swarm.Version{}, swarm.SecretSpec{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
|
||||
err = client.SecretUpdate(context.Background(), "", swarm.Version{}, swarm.SecretSpec{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
|
||||
err = client.SecretUpdate(context.Background(), " ", swarm.Version{}, swarm.SecretSpec{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user