forked from forgejo/forgejo
Consolidate boilerplate in integration tests (#1979)
This commit is contained in:
parent
a3868ef536
commit
ce9b86082c
16 changed files with 147 additions and 166 deletions
|
@ -5,9 +5,7 @@
|
|||
package integrations
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -21,15 +19,12 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
|
|||
assert.EqualValues(t, http.StatusOK, resp.HeaderCode)
|
||||
|
||||
// Click the little green button to craete a pull
|
||||
htmlDoc, err := NewHtmlParser(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
htmlDoc := NewHtmlParser(t, resp.Body)
|
||||
link, exists := htmlDoc.doc.Find("form.ui.form>button.ui.green.button").Parent().Attr("action")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
req = NewRequestBody(t, "POST", link,
|
||||
bytes.NewBufferString(url.Values{
|
||||
"_csrf": []string{htmlDoc.GetInputValueByName("_csrf")},
|
||||
}.Encode()),
|
||||
)
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
})
|
||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
resp = session.MakeRequest(t, req)
|
||||
assert.EqualValues(t, http.StatusFound, resp.HeaderCode)
|
||||
|
@ -39,7 +34,7 @@ func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum strin
|
|||
|
||||
func TestPullMerge(t *testing.T) {
|
||||
prepareTestEnv(t)
|
||||
session := loginUser(t, "user1", "password")
|
||||
session := loginUser(t, "user1")
|
||||
testRepoFork(t, session)
|
||||
testEditFile(t, session, "user1", "repo1", "master", "README.md")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue