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

Function TestHttpBody

assert/http_assertions_test.go:198–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

196}
197
198func TestHttpBody(t *testing.T) {
199 t.Parallel()
200
201 assert := New(t)
202 mockT := new(mockTestingT)
203
204 assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!"))
205 assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World"))
206 assert.False(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world"))
207
208 assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!"))
209 assert.False(HTTPBodyNotContains(
210 mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World",
211 "Expected the request body to not contain 'World'. But it did.",
212 ))
213 assert.True(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world"))
214 assert.Contains(mockT.errorString(), "Expected the request body to not contain 'World'. But it did.")
215
216 assert.True(HTTPBodyContains(mockT, httpReadBody, "GET", "/", nil, "hello"))
217}
218
219func TestHttpBodyWrappers(t *testing.T) {
220 t.Parallel()

Callers

nothing calls this directly

Calls 7

errorStringMethod · 0.80
NewFunction · 0.70
HTTPBodyContainsFunction · 0.70
HTTPBodyNotContainsFunction · 0.70
TrueMethod · 0.45
FalseMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected