summaryrefslogtreecommitdiffstats
path: root/integrations/repo_fork_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/repo_fork_test.go
parenta3868ef5367315f52334b81819a412cad820f5eb (diff)
downloadgitea-ce9b86082c4824917023b1bb480648d0cc56dd04.tar.gz
gitea-ce9b86082c4824917023b1bb480648d0cc56dd04.zip
Consolidate boilerplate in integration tests (#1979)
Diffstat (limited to 'integrations/repo_fork_test.go')
-rw-r--r--integrations/repo_fork_test.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/integrations/repo_fork_test.go b/integrations/repo_fork_test.go
index a0cf85a01e..7aebd5dbde 100644
--- a/integrations/repo_fork_test.go
+++ b/integrations/repo_fork_test.go
@@ -5,9 +5,7 @@
package integrations
import (
- "bytes"
"net/http"
- "net/url"
"testing"
"github.com/stretchr/testify/assert"
@@ -25,8 +23,7 @@ func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
// Step2: click the fork button
- htmlDoc, err := NewHtmlParser(resp.Body)
- assert.NoError(t, err)
+ htmlDoc := NewHtmlParser(t, resp.Body)
link, exists := htmlDoc.doc.Find("a.ui.button[href^=\"/repo/fork/\"]").Attr("href")
assert.True(t, exists, "The template has changed")
req = NewRequest(t, "GET", link)
@@ -34,17 +31,14 @@ func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
// Step3: fill the form of the forking
- htmlDoc, err = NewHtmlParser(resp.Body)
- assert.NoError(t, err)
+ htmlDoc = NewHtmlParser(t, resp.Body)
link, exists = htmlDoc.doc.Find("form.ui.form[action^=\"/repo/fork/\"]").Attr("action")
assert.True(t, exists, "The template has changed")
- req = NewRequestBody(t, "POST", link,
- bytes.NewBufferString(url.Values{
- "_csrf": []string{htmlDoc.GetInputValueByName("_csrf")},
- "uid": []string{"1"},
- "repo_name": []string{"repo1"},
- }.Encode()),
- )
+ req = NewRequestWithValues(t, "POST", link, map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "uid": "1",
+ "repo_name": "repo1",
+ })
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
@@ -59,6 +53,6 @@ func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
func TestRepoFork(t *testing.T) {
prepareTestEnv(t)
- session := loginUser(t, "user1", "password")
+ session := loginUser(t, "user1")
testRepoFork(t, session)
}