Less verbose integration tests (#2123)

* Helper functions for intergration test boilerplate
This commit is contained in:
Ethan Koenig 2017-07-07 15:36:47 -04:00 committed by Kim "BKC" Carlbäcker
parent 5651cc7413
commit f1adaef458
24 changed files with 121 additions and 222 deletions

View file

@ -14,21 +14,18 @@ import (
func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
// Step0: check the existence of the to-fork repo
req := NewRequest(t, "GET", "/user1/repo1")
resp := session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusNotFound, resp.HeaderCode)
resp := session.MakeRequest(t, req, http.StatusNotFound)
// Step1: go to the main page of repo
req = NewRequest(t, "GET", "/user2/repo1")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
resp = session.MakeRequest(t, req, http.StatusOK)
// Step2: click the fork button
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)
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
resp = session.MakeRequest(t, req, http.StatusOK)
// Step3: fill the form of the forking
htmlDoc = NewHTMLParser(t, resp.Body)
@ -39,13 +36,11 @@ func testRepoFork(t *testing.T, session *TestSession) *TestResponse {
"uid": "1",
"repo_name": "repo1",
})
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
resp = session.MakeRequest(t, req, http.StatusFound)
// Step4: check the existence of the forked repo
req = NewRequest(t, "GET", "/user1/repo1")
resp = session.MakeRequest(t, req)
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
resp = session.MakeRequest(t, req, http.StatusOK)
return resp
}