summaryrefslogtreecommitdiffstats
path: root/integrations/editor_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-06-09 20:41:36 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-06-09 19:41:36 -0500
commit61716bd8f70f55f2c5d4090c87700f6b9b6fc632 (patch)
treed3bab40ab681e0ccbbba964273ba32f6d0ace8e0 /integrations/editor_test.go
parent6d613fb28ef5d884bbea1e2a4d8c3e21fc398ecc (diff)
downloadgitea-61716bd8f70f55f2c5d4090c87700f6b9b6fc632.tar.gz
gitea-61716bd8f70f55f2c5d4090c87700f6b9b6fc632.zip
Display URLs in integration test logs (#1924)
Diffstat (limited to 'integrations/editor_test.go')
-rw-r--r--integrations/editor_test.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/integrations/editor_test.go b/integrations/editor_test.go
index 976def89eb..64212d3f29 100644
--- a/integrations/editor_test.go
+++ b/integrations/editor_test.go
@@ -20,8 +20,7 @@ func TestCreateFile(t *testing.T) {
session := loginUser(t, "user2", "password")
// Request editor page
- req, err := http.NewRequest("GET", "/user2/repo1/_new/master/", nil)
- assert.NoError(t, err)
+ req := NewRequest(t, "GET", "/user2/repo1/_new/master/")
resp := session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -31,7 +30,7 @@ func TestCreateFile(t *testing.T) {
assert.NotEmpty(t, lastCommit)
// Save new file to master branch
- req, err = http.NewRequest("POST", "/user2/repo1/_new/master/",
+ req = NewRequestBody(t, "POST", "/user2/repo1/_new/master/",
bytes.NewBufferString(url.Values{
"_csrf": []string{doc.GetInputValueByName("_csrf")},
"last_commit": []string{lastCommit},
@@ -40,7 +39,6 @@ func TestCreateFile(t *testing.T) {
"commit_choice": []string{"direct"},
}.Encode()),
)
- assert.NoError(t, err)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
@@ -52,8 +50,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
session := loginUser(t, "user2", "password")
// Open repository branch settings
- req, err := http.NewRequest("GET", "/user2/repo1/settings/branches", nil)
- assert.NoError(t, err)
+ req := NewRequest(t, "GET", "/user2/repo1/settings/branches")
resp := session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -61,7 +58,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
assert.NoError(t, err)
// Change master branch to protected
- req, err = http.NewRequest("POST", "/user2/repo1/settings/branches?action=protected_branch",
+ req = NewRequestBody(t, "POST", "/user2/repo1/settings/branches?action=protected_branch",
bytes.NewBufferString(url.Values{
"_csrf": []string{doc.GetInputValueByName("_csrf")},
"branchName": []string{"master"},
@@ -78,8 +75,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
assert.EqualValues(t, flashCookie.Value, "success%3Dmaster%2BLocked%2Bsuccessfully")
// Request editor page
- req, err = http.NewRequest("GET", "/user2/repo1/_new/master/", nil)
- assert.NoError(t, err)
+ req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -89,7 +85,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
assert.NotEmpty(t, lastCommit)
// Save new file to master branch
- req, err = http.NewRequest("POST", "/user2/repo1/_new/master/",
+ req = NewRequestBody(t, "POST", "/user2/repo1/_new/master/",
bytes.NewBufferString(url.Values{
"_csrf": []string{doc.GetInputValueByName("_csrf")},
"last_commit": []string{lastCommit},
@@ -98,7 +94,6 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
"commit_choice": []string{"direct"},
}.Encode()),
)
- assert.NoError(t, err)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -111,8 +106,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
newContent := "Hello, World (Edited)\n"
// Get to the 'edit this file' page
- req, err := http.NewRequest("GET", path.Join(user, repo, "_edit", branch, filePath), nil)
- assert.NoError(t, err)
+ req := NewRequest(t, "GET", path.Join(user, repo, "_edit", branch, filePath))
resp := session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
@@ -122,7 +116,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
assert.NotEmpty(t, lastCommit)
// Submit the edits
- req, err = http.NewRequest("POST", path.Join(user, repo, "_edit", branch, filePath),
+ req = NewRequestBody(t, "POST", path.Join(user, repo, "_edit", branch, filePath),
bytes.NewBufferString(url.Values{
"_csrf": []string{htmlDoc.GetInputValueByName("_csrf")},
"last_commit": []string{lastCommit},
@@ -131,14 +125,12 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
"commit_choice": []string{"direct"},
}.Encode()),
)
- assert.NoError(t, err)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
// Verify the change
- req, err = http.NewRequest("GET", path.Join(user, repo, "raw", branch, filePath), nil)
- assert.NoError(t, err)
+ req = NewRequest(t, "GET", path.Join(user, repo, "raw", branch, filePath))
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
assert.EqualValues(t, newContent, string(resp.Body))