1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

client: reduce string-matching in tests

These checks were redundant, as we were not expecting
a specific string, just that a server-error or authentication
error was returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-10-13 00:31:53 +02:00
parent d1e837d2a8
commit de10c7d013
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
91 changed files with 139 additions and 371 deletions

View file

@ -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)
}
}