From 6bec735c91c378e1c9cde1744e7c8aca7397104a Mon Sep 17 00:00:00 2001 From: Doron Podoleanu Date: Tue, 19 Jul 2016 10:40:20 +0300 Subject: [PATCH] Use const http status code instead of just numbers see #24783 Signed-off-by: Doron Podoleanu --- integration-cli/daemon.go | 2 +- integration-cli/trust_server.go | 2 +- pkg/authorization/authz_unix_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integration-cli/daemon.go b/integration-cli/daemon.go index f621d13fa2..ba0dce3054 100644 --- a/integration-cli/daemon.go +++ b/integration-cli/daemon.go @@ -400,7 +400,7 @@ func (d *Daemon) queryRootDir() (string, error) { var b []byte var i Info b, err = readBody(body) - if err == nil && resp.StatusCode == 200 { + if err == nil && resp.StatusCode == http.StatusOK { // read the docker root dir if err = json.Unmarshal(b, &i); err == nil { return i.DockerRootDir, nil diff --git a/integration-cli/trust_server.go b/integration-cli/trust_server.go index 66b53389be..7ed61fffb7 100644 --- a/integration-cli/trust_server.go +++ b/integration-cli/trust_server.go @@ -152,7 +152,7 @@ func (t *testNotary) Ping() error { if err != nil { return err } - if resp.StatusCode != 200 { + if resp.StatusCode != http.StatusOK { return fmt.Errorf("notary ping replied with an unexpected status code %d", resp.StatusCode) } return nil diff --git a/pkg/authorization/authz_unix_test.go b/pkg/authorization/authz_unix_test.go index e13303f7a5..a787f3cd8c 100644 --- a/pkg/authorization/authz_unix_test.go +++ b/pkg/authorization/authz_unix_test.go @@ -125,7 +125,7 @@ func TestResponseModifier(t *testing.T) { m := NewResponseModifier(r) m.Header().Set("h1", "v1") m.Write([]byte("body")) - m.WriteHeader(500) + m.WriteHeader(http.StatusInternalServerError) m.FlushAll() if r.Header().Get("h1") != "v1" { @@ -134,7 +134,7 @@ func TestResponseModifier(t *testing.T) { if !reflect.DeepEqual(r.Body.Bytes(), []byte("body")) { t.Fatalf("Body value must exists %s", r.Body.Bytes()) } - if r.Code != 500 { + if r.Code != http.StatusInternalServerError { t.Fatalf("Status code must be correct %d", r.Code) } } @@ -177,7 +177,7 @@ func TestResponseModifierOverride(t *testing.T) { m := NewResponseModifier(r) m.Header().Set("h1", "v1") m.Write([]byte("body")) - m.WriteHeader(500) + m.WriteHeader(http.StatusInternalServerError) overrideHeader := make(http.Header) overrideHeader.Add("h1", "v2") @@ -188,7 +188,7 @@ func TestResponseModifierOverride(t *testing.T) { m.OverrideHeader(overrideHeaderBytes) m.OverrideBody([]byte("override body")) - m.OverrideStatusCode(404) + m.OverrideStatusCode(http.StatusNotFound) m.FlushAll() if r.Header().Get("h1") != "v2" { t.Fatalf("Header value must exists %s", r.Header().Get("h1")) @@ -196,7 +196,7 @@ func TestResponseModifierOverride(t *testing.T) { if !reflect.DeepEqual(r.Body.Bytes(), []byte("override body")) { t.Fatalf("Body value must exists %s", r.Body.Bytes()) } - if r.Code != 404 { + if r.Code != http.StatusNotFound { t.Fatalf("Status code must be correct %d", r.Code) } }