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

Function HTTPBodyNotContains

assert/http_assertions.go:153–165  ·  assert/http_assertions.go::HTTPBodyNotContains

HTTPBodyNotContains asserts that a specified handler returns a body that does not contain a string. assert.HTTPBodyNotContains(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

151//
152// Returns whether the assertion was successful (true) or not (false).
153func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
154 if h, ok := t.(tHelper); ok {
155 h.Helper()
156 }
157 body := HTTPBody(handler, method, url, values)
158
159 contains := strings.Contains(body, fmt.Sprint(str))
160 if contains {
161 Fail(t, fmt.Sprintf("Expected response body for %q to NOT contain %q but found %q", url+"?"+values.Encode(), str, body), msgAndArgs...)
162 }
163
164 return !contains
165}

Callers 4

HTTPBodyNotContainsFunction · 0.92
HTTPBodyNotContainsfFunction · 0.70
TestHttpBodyFunction · 0.70
HTTPBodyNotContainsMethod · 0.70

Calls 4

HTTPBodyFunction · 0.85
FailFunction · 0.70
HelperMethod · 0.65
ContainsMethod · 0.45

Tested by 1

TestHttpBodyFunction · 0.56