Merge pull request #24784 from doronp/UseHTTPCodes
Use const http status code instead of just numbers see #24783
This commit is contained in:
commit
5c53fd468b
3 changed files with 7 additions and 7 deletions
|
@ -400,7 +400,7 @@ func (d *Daemon) queryRootDir() (string, error) {
|
||||||
var b []byte
|
var b []byte
|
||||||
var i Info
|
var i Info
|
||||||
b, err = readBody(body)
|
b, err = readBody(body)
|
||||||
if err == nil && resp.StatusCode == 200 {
|
if err == nil && resp.StatusCode == http.StatusOK {
|
||||||
// read the docker root dir
|
// read the docker root dir
|
||||||
if err = json.Unmarshal(b, &i); err == nil {
|
if err = json.Unmarshal(b, &i); err == nil {
|
||||||
return i.DockerRootDir, nil
|
return i.DockerRootDir, nil
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (t *testNotary) Ping() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 fmt.Errorf("notary ping replied with an unexpected status code %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -125,7 +125,7 @@ func TestResponseModifier(t *testing.T) {
|
||||||
m := NewResponseModifier(r)
|
m := NewResponseModifier(r)
|
||||||
m.Header().Set("h1", "v1")
|
m.Header().Set("h1", "v1")
|
||||||
m.Write([]byte("body"))
|
m.Write([]byte("body"))
|
||||||
m.WriteHeader(500)
|
m.WriteHeader(http.StatusInternalServerError)
|
||||||
|
|
||||||
m.FlushAll()
|
m.FlushAll()
|
||||||
if r.Header().Get("h1") != "v1" {
|
if r.Header().Get("h1") != "v1" {
|
||||||
|
@ -134,7 +134,7 @@ func TestResponseModifier(t *testing.T) {
|
||||||
if !reflect.DeepEqual(r.Body.Bytes(), []byte("body")) {
|
if !reflect.DeepEqual(r.Body.Bytes(), []byte("body")) {
|
||||||
t.Fatalf("Body value must exists %s", r.Body.Bytes())
|
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)
|
t.Fatalf("Status code must be correct %d", r.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ func TestResponseModifierOverride(t *testing.T) {
|
||||||
m := NewResponseModifier(r)
|
m := NewResponseModifier(r)
|
||||||
m.Header().Set("h1", "v1")
|
m.Header().Set("h1", "v1")
|
||||||
m.Write([]byte("body"))
|
m.Write([]byte("body"))
|
||||||
m.WriteHeader(500)
|
m.WriteHeader(http.StatusInternalServerError)
|
||||||
|
|
||||||
overrideHeader := make(http.Header)
|
overrideHeader := make(http.Header)
|
||||||
overrideHeader.Add("h1", "v2")
|
overrideHeader.Add("h1", "v2")
|
||||||
|
@ -188,7 +188,7 @@ func TestResponseModifierOverride(t *testing.T) {
|
||||||
|
|
||||||
m.OverrideHeader(overrideHeaderBytes)
|
m.OverrideHeader(overrideHeaderBytes)
|
||||||
m.OverrideBody([]byte("override body"))
|
m.OverrideBody([]byte("override body"))
|
||||||
m.OverrideStatusCode(404)
|
m.OverrideStatusCode(http.StatusNotFound)
|
||||||
m.FlushAll()
|
m.FlushAll()
|
||||||
if r.Header().Get("h1") != "v2" {
|
if r.Header().Get("h1") != "v2" {
|
||||||
t.Fatalf("Header value must exists %s", r.Header().Get("h1"))
|
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")) {
|
if !reflect.DeepEqual(r.Body.Bytes(), []byte("override body")) {
|
||||||
t.Fatalf("Body value must exists %s", r.Body.Bytes())
|
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)
|
t.Fatalf("Status code must be correct %d", r.Code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue