aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/integration_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-24 20:15:42 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-25 08:15:42 +0800
commitf64c232953d13043b262dc8da55acb3738e58d15 (patch)
tree9f1e88ff351e10be789783254fa51f8fe9c342a7 /integrations/integration_test.go
parent3ffedeab03a80e7345823d118042d17a3e3d9b52 (diff)
downloadgitea-f64c232953d13043b262dc8da55acb3738e58d15.tar.gz
gitea-f64c232953d13043b262dc8da55acb3738e58d15.zip
Improve integration test helper functions (#2049)
Set request headers in helper functions, and new helper for requests with string-formatted URLs
Diffstat (limited to 'integrations/integration_test.go')
-rw-r--r--integrations/integration_test.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index 84b05cb644..9332e12187 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -173,7 +173,6 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
"user_name": userName,
"password": password,
})
- req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = MakeRequest(req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
@@ -218,12 +217,18 @@ func NewRequest(t testing.TB, method, urlStr string) *http.Request {
return NewRequestWithBody(t, method, urlStr, nil)
}
+func NewRequestf(t testing.TB, method, urlFormat string, args ...interface{}) *http.Request {
+ return NewRequest(t, method, fmt.Sprintf(urlFormat, args...))
+}
+
func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string]string) *http.Request {
urlValues := url.Values{}
for key, value := range values {
urlValues[key] = []string{value}
}
- return NewRequestWithBody(t, method, urlStr, bytes.NewBufferString(urlValues.Encode()))
+ req := NewRequestWithBody(t, method, urlStr, bytes.NewBufferString(urlValues.Encode()))
+ req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
+ return req
}
func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {