mirror of https://github.com/stretchr/testify.git
go format
parent
2adb7b54b7
commit
9d083cac4a
|
@ -115,8 +115,8 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va
|
|||
func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values, body io.Reader) string {
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
if values !=nil {
|
||||
url = url+"?"+values.Encode()
|
||||
if values != nil {
|
||||
url = url + "?" + values.Encode()
|
||||
}
|
||||
req, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
|
@ -136,7 +136,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string,
|
|||
if h, ok := t.(tHelper); ok {
|
||||
h.Helper()
|
||||
}
|
||||
httpBody := HTTPBody(handler, method, url, values, body)
|
||||
httpBody := HTTPBody(handler, method, url, values, body)
|
||||
|
||||
contains := strings.Contains(httpBody, fmt.Sprint(str))
|
||||
if !contains {
|
||||
|
|
|
@ -173,13 +173,13 @@ func TestHttpBodyWrappers(t *testing.T) {
|
|||
assert := New(t)
|
||||
mockAssert := New(new(testing.T))
|
||||
|
||||
assert.True(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil,"Hello, World!"))
|
||||
assert.True(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil,"World"))
|
||||
assert.False(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil,"world"))
|
||||
assert.True(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "Hello, World!"))
|
||||
assert.True(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "World"))
|
||||
assert.False(mockAssert.HTTPBodyContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "world"))
|
||||
|
||||
assert.False(mockAssert.HTTPBodyNotContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "Hello, World!"))
|
||||
assert.False(mockAssert.HTTPBodyNotContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil,"World"))
|
||||
assert.True(mockAssert.HTTPBodyNotContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil,"world"))
|
||||
assert.False(mockAssert.HTTPBodyNotContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "World"))
|
||||
assert.True(mockAssert.HTTPBodyNotContains(httpGetHelloNameHandler, "GET", "/", url.Values{"name": []string{"World"}}, nil, "world"))
|
||||
}
|
||||
|
||||
func httpGetHelloNameHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -195,4 +195,4 @@ func httpPostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
w.Write(body)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue