MCPcopy
hub / github.com/stretchr/testify / httpCode

Function httpCode

assert/http_assertions.go:13–22  ·  assert/http_assertions.go::httpCode

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)

Source from the content-addressed store, hash-verified

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.
13func 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//

Callers 4

HTTPSuccessFunction · 0.85
HTTPRedirectFunction · 0.85
HTTPErrorFunction · 0.85
HTTPStatusCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected