aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/stretchr/testify/assert/http_assertions.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-06-08 10:11:43 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-06-08 13:17:19 -0400
commitedf733c3b60c5aaf922e894a0470d015bd23e0dc (patch)
tree9e9a00466e29daf93171508b5e90a2088835efbc /vendor/github.com/stretchr/testify/assert/http_assertions.go
parent2869cce1d53aedfe2500f3d921fb901dd5994690 (diff)
downloadpodman-edf733c3b60c5aaf922e894a0470d015bd23e0dc.tar.gz
podman-edf733c3b60c5aaf922e894a0470d015bd23e0dc.tar.bz2
podman-edf733c3b60c5aaf922e894a0470d015bd23e0dc.zip
Bump github.com/stretchr/testify from 1.6.0 to 1.6.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.6.0...v1.6.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/stretchr/testify/assert/http_assertions.go')
-rw-r--r--vendor/github.com/stretchr/testify/assert/http_assertions.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go
index 30ef7cc06..4ed341dd2 100644
--- a/vendor/github.com/stretchr/testify/assert/http_assertions.go
+++ b/vendor/github.com/stretchr/testify/assert/http_assertions.go
@@ -2,7 +2,6 @@ package assert
import (
"fmt"
- "io"
"net/http"
"net/http/httptest"
"net/url"
@@ -112,13 +111,9 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va
// HTTPBody is a helper that returns HTTP body of the response. It returns
// empty string if building a new request fails.
-func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values, body io.Reader) string {
+func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string {
w := httptest.NewRecorder()
-
- if values != nil {
- url = url + "?" + values.Encode()
- }
- req, err := http.NewRequest(method, url, body)
+ req, err := http.NewRequest(method, url+"?"+values.Encode(), nil)
if err != nil {
return ""
}
@@ -132,13 +127,13 @@ func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values, b
// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, body io.Reader, str interface{}, msgAndArgs ...interface{}) bool {
+func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
- httpBody := HTTPBody(handler, method, url, values, body)
+ body := HTTPBody(handler, method, url, values)
- contains := strings.Contains(httpBody, fmt.Sprint(str))
+ contains := strings.Contains(body, fmt.Sprint(str))
if !contains {
Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
}
@@ -152,13 +147,13 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string,
// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky")
//
// Returns whether the assertion was successful (true) or not (false).
-func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, body io.Reader, str interface{}, msgAndArgs ...interface{}) bool {
+func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool {
if h, ok := t.(tHelper); ok {
h.Helper()
}
- httpBody := HTTPBody(handler, method, url, values, body)
+ body := HTTPBody(handler, method, url, values)
- contains := strings.Contains(httpBody, fmt.Sprint(str))
+ contains := strings.Contains(body, fmt.Sprint(str))
if contains {
Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body))
}