MCPcopy
hub / github.com/expr-lang/expr / HTTPRedirect

Function HTTPRedirect

internal/testify/assert/http_assertions.go:51–66  ·  view source on GitHub ↗

HTTPRedirect asserts that a specified handler returns a redirect status code. assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} Returns whether the assertion was successful (true) or not (false).

(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

49//
50// Returns whether the assertion was successful (true) or not (false).
51func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool {
52 if h, ok := t.(tHelper); ok {
53 h.Helper()
54 }
55 code, err := httpCode(handler, method, url, values)
56 if err != nil {
57 Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...)
58 }
59
60 isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect
61 if !isRedirectCode {
62 Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...)
63 }
64
65 return isRedirectCode
66}
67
68// HTTPError asserts that a specified handler returns an error status code.
69//

Callers 4

HTTPRedirectFunction · 0.92
HTTPRedirectfFunction · 0.70
TestHTTPRedirectFunction · 0.70
HTTPRedirectMethod · 0.70

Calls 4

httpCodeFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestHTTPRedirectFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…