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{})
| 151 | // |
| 152 | // Returns whether the assertion was successful (true) or not (false). |
| 153 | func 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 | } |