From 46b80550c1fb357669d17644abae236252a879a7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 14 Jan 2019 21:47:30 +0100 Subject: [PATCH] Fix ping-tests using wrong status-code Signed-off-by: Sebastiaan van Stijn --- client/ping_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/client/ping_test.go b/client/ping_test.go index 10bbbe811d..1f57a8d1ce 100644 --- a/client/ping_test.go +++ b/client/ping_test.go @@ -32,13 +32,13 @@ func TestPingFail(t *testing.T) { } ping, err := client.Ping(context.Background()) - assert.Check(t, is.ErrorContains(err, "")) + assert.ErrorContains(t, err, "some error with the server") assert.Check(t, is.Equal(false, ping.Experimental)) assert.Check(t, is.Equal("", ping.APIVersion)) withHeader = true ping2, err := client.Ping(context.Background()) - assert.Check(t, is.ErrorContains(err, "")) + assert.ErrorContains(t, err, "some error with the server") assert.Check(t, is.Equal(true, ping2.Experimental)) assert.Check(t, is.Equal("awesome", ping2.APIVersion)) } @@ -58,7 +58,7 @@ func TestPingWithError(t *testing.T) { } ping, err := client.Ping(context.Background()) - assert.Check(t, is.ErrorContains(err, "")) + assert.ErrorContains(t, err, "some error") assert.Check(t, is.Equal(false, ping.Experimental)) assert.Check(t, is.Equal("", ping.APIVersion)) } @@ -68,16 +68,16 @@ func TestPingWithError(t *testing.T) { func TestPingSuccess(t *testing.T) { client := &Client{ client: newMockClient(func(req *http.Request) (*http.Response, error) { - resp := &http.Response{StatusCode: http.StatusInternalServerError} + resp := &http.Response{StatusCode: http.StatusOK} resp.Header = http.Header{} resp.Header.Set("API-Version", "awesome") resp.Header.Set("Docker-Experimental", "true") - resp.Body = ioutil.NopCloser(strings.NewReader("some error with the server")) + resp.Body = ioutil.NopCloser(strings.NewReader("OK")) return resp, nil }), } ping, err := client.Ping(context.Background()) - assert.Check(t, is.ErrorContains(err, "")) + assert.NilError(t, err) assert.Check(t, is.Equal(true, ping.Experimental)) assert.Check(t, is.Equal("awesome", ping.APIVersion)) }