Browse code

Use const http status code instead of just numbers see #24783

Signed-off-by: Doron Podoleanu <doronp@il.ibm.com>

Doron Podoleanu authored on 2016/07/19 16:40:20
Showing 3 changed files
... ...
@@ -400,7 +400,7 @@ func (d *Daemon) queryRootDir() (string, error) {
400 400
 	var b []byte
401 401
 	var i Info
402 402
 	b, err = readBody(body)
403
-	if err == nil && resp.StatusCode == 200 {
403
+	if err == nil && resp.StatusCode == http.StatusOK {
404 404
 		// read the docker root dir
405 405
 		if err = json.Unmarshal(b, &i); err == nil {
406 406
 			return i.DockerRootDir, nil
... ...
@@ -152,7 +152,7 @@ func (t *testNotary) Ping() error {
152 152
 	if err != nil {
153 153
 		return err
154 154
 	}
155
-	if resp.StatusCode != 200 {
155
+	if resp.StatusCode != http.StatusOK {
156 156
 		return fmt.Errorf("notary ping replied with an unexpected status code %d", resp.StatusCode)
157 157
 	}
158 158
 	return nil
... ...
@@ -125,7 +125,7 @@ func TestResponseModifier(t *testing.T) {
125 125
 	m := NewResponseModifier(r)
126 126
 	m.Header().Set("h1", "v1")
127 127
 	m.Write([]byte("body"))
128
-	m.WriteHeader(500)
128
+	m.WriteHeader(http.StatusInternalServerError)
129 129
 
130 130
 	m.FlushAll()
131 131
 	if r.Header().Get("h1") != "v1" {
... ...
@@ -134,7 +134,7 @@ func TestResponseModifier(t *testing.T) {
134 134
 	if !reflect.DeepEqual(r.Body.Bytes(), []byte("body")) {
135 135
 		t.Fatalf("Body value must exists %s", r.Body.Bytes())
136 136
 	}
137
-	if r.Code != 500 {
137
+	if r.Code != http.StatusInternalServerError {
138 138
 		t.Fatalf("Status code must be correct %d", r.Code)
139 139
 	}
140 140
 }
... ...
@@ -177,7 +177,7 @@ func TestResponseModifierOverride(t *testing.T) {
177 177
 	m := NewResponseModifier(r)
178 178
 	m.Header().Set("h1", "v1")
179 179
 	m.Write([]byte("body"))
180
-	m.WriteHeader(500)
180
+	m.WriteHeader(http.StatusInternalServerError)
181 181
 
182 182
 	overrideHeader := make(http.Header)
183 183
 	overrideHeader.Add("h1", "v2")
... ...
@@ -188,7 +188,7 @@ func TestResponseModifierOverride(t *testing.T) {
188 188
 
189 189
 	m.OverrideHeader(overrideHeaderBytes)
190 190
 	m.OverrideBody([]byte("override body"))
191
-	m.OverrideStatusCode(404)
191
+	m.OverrideStatusCode(http.StatusNotFound)
192 192
 	m.FlushAll()
193 193
 	if r.Header().Get("h1") != "v2" {
194 194
 		t.Fatalf("Header value must exists %s", r.Header().Get("h1"))
... ...
@@ -196,7 +196,7 @@ func TestResponseModifierOverride(t *testing.T) {
196 196
 	if !reflect.DeepEqual(r.Body.Bytes(), []byte("override body")) {
197 197
 		t.Fatalf("Body value must exists %s", r.Body.Bytes())
198 198
 	}
199
-	if r.Code != 404 {
199
+	if r.Code != http.StatusNotFound {
200 200
 		t.Fatalf("Status code must be correct %d", r.Code)
201 201
 	}
202 202
 }