mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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:
@@ -14,6 +14,8 @@ import (
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
|
||||
func TestImageSearchAnyError(t *testing.T) {
|
||||
@@ -21,9 +23,7 @@ func TestImageSearchAnyError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
|
||||
if !errdefs.IsSystem(err) {
|
||||
t.Fatalf("expected a Server Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
}
|
||||
|
||||
func TestImageSearchStatusUnauthorizedError(t *testing.T) {
|
||||
@@ -31,9 +31,7 @@ func TestImageSearchStatusUnauthorizedError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusUnauthorized, "Unauthorized error")),
|
||||
}
|
||||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{})
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
|
||||
}
|
||||
|
||||
func TestImageSearchWithUnauthorizedErrorAndPrivilegeFuncError(t *testing.T) {
|
||||
@@ -61,9 +59,7 @@ func TestImageSearchWithUnauthorizedErrorAndAnotherUnauthorizedError(t *testing.
|
||||
_, err := client.ImageSearch(context.Background(), "some-image", types.ImageSearchOptions{
|
||||
PrivilegeFunc: privilegeFunc,
|
||||
})
|
||||
if !errdefs.IsUnauthorized(err) {
|
||||
t.Fatalf("expected a Unauthorized Error, got %[1]T: %[1]v", err)
|
||||
}
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsUnauthorized))
|
||||
}
|
||||
|
||||
func TestImageSearchWithPrivilegedFuncNoError(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user