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

Function HTTPBodyContains

internal/testify/assert/http_assertions.go:133–145  ·  view source on GitHub ↗

HTTPBodyContains asserts that a specified handler returns a body that contains a string. assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") Returns whether the assertion was successful (true) or not (false).

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

Source from the content-addressed store, hash-verified

131//
132// Returns whether the assertion was successful (true) or not (false).
133func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
134 if h, ok := t.(tHelper); ok {
135 h.Helper()
136 }
137 body := HTTPBody(handler, method, url, values)
138
139 contains := strings.Contains(body, fmt.Sprint(str))
140 if !contains {
141 Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body), msgAndArgs...)
142 }
143
144 return contains
145}
146
147// HTTPBodyNotContains asserts that a specified handler returns a
148// body that does not contain a string.

Callers 4

HTTPBodyContainsFunction · 0.92
HTTPBodyContainsfFunction · 0.70
TestHttpBodyFunction · 0.70
HTTPBodyContainsMethod · 0.70

Calls 6

HTTPBodyFunction · 0.85
SprintMethod · 0.80
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45
ContainsMethod · 0.45

Tested by 1

TestHttpBodyFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…