httpCode is a helper that returns HTTP code of the response. It returns -1 and an error if building a new request fails.
(handler http.HandlerFunc, method, url string, values url.Values)
| 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 and |
| 12 | // an error if building a new request fails. |
| 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { |
| 14 | w := httptest.NewRecorder() |
| 15 | req, err := http.NewRequest(method, url, http.NoBody) |
| 16 | if err != nil { |
| 17 | return -1, err |
| 18 | } |
| 19 | req.URL.RawQuery = values.Encode() |
| 20 | handler(w, req) |
| 21 | return w.Code, nil |
| 22 | } |
| 23 | |
| 24 | // HTTPSuccess asserts that a specified handler returns a success status code. |
| 25 | // |
no outgoing calls
no test coverage detected