Skip to content

Commit

Permalink
Use const http status code instead of just numbers see moby#24783
Browse files Browse the repository at this point in the history
Signed-off-by: Doron Podoleanu <[email protected]>
  • Loading branch information
Doron Podoleanu committed Jul 19, 2016
1 parent 5fe3e00 commit 6bec735
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion integration-cli/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/trust_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/authorization/authz_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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")
Expand All @@ -188,15 +188,15 @@ 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"))
}
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)
}
}
Expand Down

0 comments on commit 6bec735

Please sign in to comment.