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

Fix ping-tests using wrong status-code

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-01-14 21:47:30 +01:00
parent beef00cb26
commit 46b80550c1
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -32,13 +32,13 @@ func TestPingFail(t *testing.T) {
} }
ping, err := client.Ping(context.Background()) 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(false, ping.Experimental))
assert.Check(t, is.Equal("", ping.APIVersion)) assert.Check(t, is.Equal("", ping.APIVersion))
withHeader = true withHeader = true
ping2, err := client.Ping(context.Background()) 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(true, ping2.Experimental))
assert.Check(t, is.Equal("awesome", ping2.APIVersion)) assert.Check(t, is.Equal("awesome", ping2.APIVersion))
} }
@ -58,7 +58,7 @@ func TestPingWithError(t *testing.T) {
} }
ping, err := client.Ping(context.Background()) 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(false, ping.Experimental))
assert.Check(t, is.Equal("", ping.APIVersion)) assert.Check(t, is.Equal("", ping.APIVersion))
} }
@ -68,16 +68,16 @@ func TestPingWithError(t *testing.T) {
func TestPingSuccess(t *testing.T) { func TestPingSuccess(t *testing.T) {
client := &Client{ client := &Client{
client: newMockClient(func(req *http.Request) (*http.Response, error) { 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 = http.Header{}
resp.Header.Set("API-Version", "awesome") resp.Header.Set("API-Version", "awesome")
resp.Header.Set("Docker-Experimental", "true") 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 return resp, nil
}), }),
} }
ping, err := client.Ping(context.Background()) 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(true, ping.Experimental))
assert.Check(t, is.Equal("awesome", ping.APIVersion)) assert.Check(t, is.Equal("awesome", ping.APIVersion))
} }