mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
Less verbose integration tests (#2123)
* Helper functions for intergration test boilerplate
This commit is contained in:
committed by
Kim "BKC" Carlbäcker
parent
5651cc7413
commit
f1adaef458
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user