diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-06-09 20:41:36 -0400 |
---|---|---|
committer | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-06-09 19:41:36 -0500 |
commit | 61716bd8f70f55f2c5d4090c87700f6b9b6fc632 (patch) | |
tree | d3bab40ab681e0ccbbba964273ba32f6d0ace8e0 /integrations/integration_test.go | |
parent | 6d613fb28ef5d884bbea1e2a4d8c3e21fc398ecc (diff) | |
download | gitea-61716bd8f70f55f2c5d4090c87700f6b9b6fc632.tar.gz gitea-61716bd8f70f55f2c5d4090c87700f6b9b6fc632.zip |
Display URLs in integration test logs (#1924)
Diffstat (limited to 'integrations/integration_test.go')
-rw-r--r-- | integrations/integration_test.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go index 88b4614b76..1cc1eb049f 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -147,22 +147,20 @@ func (s *TestSession) MakeRequest(t *testing.T, req *http.Request) *TestResponse } func loginUser(t *testing.T, userName, password string) *TestSession { - req, err := http.NewRequest("GET", "/user/login", nil) - assert.NoError(t, err) + req := NewRequest(t, "GET", "/user/login") resp := MakeRequest(req) assert.EqualValues(t, http.StatusOK, resp.HeaderCode) doc, err := NewHtmlParser(resp.Body) assert.NoError(t, err) - req, err = http.NewRequest("POST", "/user/login", + req = NewRequestBody(t, "POST", "/user/login", bytes.NewBufferString(url.Values{ "_csrf": []string{doc.GetInputValueByName("_csrf")}, "user_name": []string{userName}, "password": []string{password}, }.Encode()), ) - assert.NoError(t, err) req.Header.Add("Content-Type", "application/x-www-form-urlencoded") resp = MakeRequest(req) assert.EqualValues(t, http.StatusFound, resp.HeaderCode) @@ -204,6 +202,17 @@ type TestResponse struct { Headers http.Header } +func NewRequest(t *testing.T, method, url string) *http.Request { + return NewRequestBody(t, method, url, nil) +} + +func NewRequestBody(t *testing.T, method, url string, body io.Reader) *http.Request { + request, err := http.NewRequest(method, url, body) + assert.NoError(t, err) + request.RequestURI = url + return request +} + func MakeRequest(req *http.Request) *TestResponse { buffer := bytes.NewBuffer(nil) respWriter := &TestResponseWriter{ |