Skip to content

Commit c205979

Browse files
Allow testing of DoRequest against status code
The following changes are required so we can test against the status code along with the error of a http request. Changing this allows us to work with go-1.12 where the changes to the http(s) server when calling https using http now returns a 400 status code instead of malformed garbage. See: https://go-review.googlesource.com/c/go/+/98447/
1 parent dfc56b8 commit c205979

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

httptesting/http.go

+7
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ type DoRequestParams struct {
165165
// nil.
166166
ExpectError string
167167

168+
// ExpectStatus holds the expected HTTP status code.
169+
// If unset or zero, then no check is performed.
170+
ExpectStatus int
171+
168172
// Method holds the HTTP method to use for the call.
169173
// GET is assumed if this is empty.
170174
Method string
@@ -276,6 +280,9 @@ func Do(c *gc.C, p DoRequestParams) *http.Response {
276280
return nil
277281
}
278282
c.Assert(err, jc.ErrorIsNil)
283+
if p.ExpectStatus != 0 {
284+
c.Assert(resp.StatusCode, gc.Equals, p.ExpectStatus)
285+
}
279286
return resp
280287
}
281288

0 commit comments

Comments
 (0)