mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-16 15:02:43 +00:00
Use httptest in integration tests (#3080)
This commit is contained in:
parent
993b86628b
commit
e59adcde65
12 changed files with 77 additions and 100 deletions
|
@ -59,9 +59,8 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
|
|||
link, exists := htmlDoc.doc.Find(button).Attr("data-url")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
|
||||
htmlDoc = NewHTMLParser(t, resp.Body)
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": getCsrf(htmlDoc.doc),
|
||||
"_csrf": getCsrf(t, htmlDoc.doc),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
|
@ -73,7 +72,8 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
|
|||
return NewHTMLParser(t, resp.Body), url.Query()["name"][0]
|
||||
}
|
||||
|
||||
func getCsrf(doc *goquery.Document) string {
|
||||
csrf, _ := doc.Find("meta[name=\"_csrf\"]").Attr("content")
|
||||
func getCsrf(t *testing.T, doc *goquery.Document) string {
|
||||
csrf, exists := doc.Find("meta[name=\"_csrf\"]").Attr("content")
|
||||
assert.True(t, exists)
|
||||
return csrf
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue