Skip to content

Commit 835b6c0

Browse files
Only test when non-zero
1 parent e25f034 commit 835b6c0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

httptesting/http.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ type DoRequestParams struct {
166166
ExpectError string
167167

168168
// ExpectStatus holds the expected HTTP status code.
169-
// http.StatusOK is assumed if this is zero.
169+
// If unset or zero, then no check is performed.
170170
ExpectStatus int
171171

172172
// Method holds the HTTP method to use for the call.
@@ -280,14 +280,9 @@ func Do(c *gc.C, p DoRequestParams) *http.Response {
280280
return nil
281281
}
282282
c.Assert(err, jc.ErrorIsNil)
283-
// Check the status even if the expected status is zero.
284-
// This should ensure that the server is responding correctly,
285-
// or at least your tests are.
286-
expectedStatus := p.ExpectStatus
287-
if expectedStatus == 0 {
288-
expectedStatus = http.StatusOK
283+
if p.ExpectStatus != 0 {
284+
c.Assert(resp.StatusCode, gc.Equals, p.ExpectStatus)
289285
}
290-
c.Assert(resp.StatusCode, gc.Equals, expectedStatus)
291286
return resp
292287
}
293288

0 commit comments

Comments
 (0)