diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-07-07 15:36:47 -0400 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2017-07-07 21:36:47 +0200 |
commit | f1adaef45849fc260b07be39a39b9c1ee5146923 (patch) | |
tree | bc33151ef4021ae14adf2e6cfc694b9e4729cef8 /integrations/issue_test.go | |
parent | 5651cc7413640f12a9eb8dee64d332ea9597afce (diff) | |
download | gitea-f1adaef45849fc260b07be39a39b9c1ee5146923.tar.gz gitea-f1adaef45849fc260b07be39a39b9c1ee5146923.zip |
Less verbose integration tests (#2123)
* Helper functions for intergration test boilerplate
Diffstat (limited to 'integrations/issue_test.go')
-rw-r--r-- | integrations/issue_test.go | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/integrations/issue_test.go b/integrations/issue_test.go index 320dad0666..e728e4a154 100644 --- a/integrations/issue_test.go +++ b/integrations/issue_test.go @@ -35,8 +35,7 @@ func TestNoLoginViewIssues(t *testing.T) { prepareTestEnv(t) req := NewRequest(t, "GET", "/user2/repo1/issues") - resp := MakeRequest(req) - assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + MakeRequest(t, req, http.StatusOK) } func TestNoLoginViewIssuesSortByType(t *testing.T) { @@ -48,8 +47,7 @@ func TestNoLoginViewIssuesSortByType(t *testing.T) { session := loginUser(t, user.Name) req := NewRequest(t, "GET", repo.RelLink()+"/issues?type=created_by") - resp := session.MakeRequest(t, req) - assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) issuesSelection := getIssuesSelection(htmlDoc) @@ -73,15 +71,13 @@ func TestNoLoginViewIssue(t *testing.T) { prepareTestEnv(t) req := NewRequest(t, "GET", "/user2/repo1/issues/1") - resp := MakeRequest(req) - assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + MakeRequest(t, req, http.StatusOK) } func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) { req := NewRequest(t, "GET", path.Join(user, repo, "issues", "new")) - resp := session.MakeRequest(t, req) - assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + resp := session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action") @@ -90,14 +86,10 @@ func testNewIssue(t *testing.T, session *TestSession, user, repo, title string) "_csrf": htmlDoc.GetCSRF(), "title": title, }) - resp = session.MakeRequest(t, req) - assert.EqualValues(t, http.StatusFound, resp.HeaderCode) - redirectedURL := resp.Headers["Location"] - assert.NotEmpty(t, redirectedURL, "Redirected URL is not found") - - req = NewRequest(t, "GET", redirectedURL[0]) - resp = session.MakeRequest(t, req) - assert.EqualValues(t, http.StatusOK, resp.HeaderCode) + resp = session.MakeRequest(t, req, http.StatusFound) + + req = NewRequest(t, "GET", RedirectURL(t, resp)) + resp = session.MakeRequest(t, req, http.StatusOK) } func TestNewIssue(t *testing.T) { |