summaryrefslogtreecommitdiffstats
path: root/integrations/pull_create_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-17 00:49:45 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-17 12:49:45 +0800
commitce9b86082c4824917023b1bb480648d0cc56dd04 (patch)
treeba28673c955d009492557f54953857165e2f8da8 /integrations/pull_create_test.go
parenta3868ef5367315f52334b81819a412cad820f5eb (diff)
downloadgitea-ce9b86082c4824917023b1bb480648d0cc56dd04.tar.gz
gitea-ce9b86082c4824917023b1bb480648d0cc56dd04.zip
Consolidate boilerplate in integration tests (#1979)
Diffstat (limited to 'integrations/pull_create_test.go')
-rw-r--r--integrations/pull_create_test.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/integrations/pull_create_test.go b/integrations/pull_create_test.go
index ac8df33c6a..f518c1bb55 100644
--- a/integrations/pull_create_test.go
+++ b/integrations/pull_create_test.go
@@ -5,9 +5,7 @@
package integrations
import (
- "bytes"
"net/http"
- "net/url"
"path"
"testing"
@@ -20,8 +18,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
// Click the little green button to create a pull
- htmlDoc, err := NewHtmlParser(resp.Body)
- assert.NoError(t, err)
+ htmlDoc := NewHtmlParser(t, resp.Body)
link, exists := htmlDoc.doc.Find("button.ui.green.small.button").Parent().Attr("href")
assert.True(t, exists, "The template has changed")
@@ -30,16 +27,13 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
// Submit the form for creating the pull
- htmlDoc, err = NewHtmlParser(resp.Body)
- assert.NoError(t, err)
+ htmlDoc = NewHtmlParser(t, resp.Body)
link, exists = htmlDoc.doc.Find("form.ui.form").Attr("action")
assert.True(t, exists, "The template has changed")
- req = NewRequestBody(t, "POST", link,
- bytes.NewBufferString(url.Values{
- "_csrf": []string{htmlDoc.GetInputValueByName("_csrf")},
- "title": []string{"This is a pull title"},
- }.Encode()),
- )
+ req = NewRequestWithValues(t, "POST", link, map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "title": "This is a pull title",
+ })
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
@@ -51,7 +45,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
func TestPullCreate(t *testing.T) {
prepareTestEnv(t)
- session := loginUser(t, "user1", "password")
+ session := loginUser(t, "user1")
testRepoFork(t, session)
testEditFile(t, session, "user1", "repo1", "master", "README.md")
testPullCreate(t, session, "user1", "repo1", "master")