summaryrefslogtreecommitdiffstats
path: root/integrations/change_default_branch_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-07-07 15:36:47 -0400
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-07-07 21:36:47 +0200
commitf1adaef45849fc260b07be39a39b9c1ee5146923 (patch)
treebc33151ef4021ae14adf2e6cfc694b9e4729cef8 /integrations/change_default_branch_test.go
parent5651cc7413640f12a9eb8dee64d332ea9597afce (diff)
downloadgitea-f1adaef45849fc260b07be39a39b9c1ee5146923.tar.gz
gitea-f1adaef45849fc260b07be39a39b9c1ee5146923.zip
Less verbose integration tests (#2123)
* Helper functions for intergration test boilerplate
Diffstat (limited to 'integrations/change_default_branch_test.go')
-rw-r--r--integrations/change_default_branch_test.go26
1 files changed, 7 insertions, 19 deletions
diff --git a/integrations/change_default_branch_test.go b/integrations/change_default_branch_test.go
index 07bc41a18e..dbd189cd28 100644
--- a/integrations/change_default_branch_test.go
+++ b/integrations/change_default_branch_test.go
@@ -10,8 +10,6 @@ import (
"testing"
"code.gitea.io/gitea/models"
-
- "github.com/stretchr/testify/assert"
)
func TestChangeDefaultBranch(t *testing.T) {
@@ -22,29 +20,19 @@ func TestChangeDefaultBranch(t *testing.T) {
session := loginUser(t, owner.Name)
branchesURL := fmt.Sprintf("/%s/%s/settings/branches", owner.Name, repo.Name)
- req := NewRequest(t, "GET", branchesURL)
- resp := session.MakeRequest(t, req)
- assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
- doc := NewHTMLParser(t, resp.Body)
-
- req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
- "_csrf": doc.GetCSRF(),
+ csrf := GetCSRF(t, session, branchesURL)
+ req := NewRequestWithValues(t, "POST", branchesURL, map[string]string{
+ "_csrf": csrf,
"action": "default_branch",
"branch": "DefaultBranch",
})
- resp = session.MakeRequest(t, req)
- assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
-
- req = NewRequest(t, "GET", branchesURL)
- resp = session.MakeRequest(t, req)
- assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
- doc = NewHTMLParser(t, resp.Body)
+ session.MakeRequest(t, req, http.StatusFound)
+ csrf = GetCSRF(t, session, branchesURL)
req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
- "_csrf": doc.GetInputValueByName("_csrf"),
+ "_csrf": csrf,
"action": "default_branch",
"branch": "does_not_exist",
})
- resp = session.MakeRequest(t, req)
- assert.EqualValues(t, http.StatusNotFound, resp.HeaderCode)
+ session.MakeRequest(t, req, http.StatusNotFound)
}