mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Consolidate boilerplate in integration tests (#1979)
This commit is contained in:
		@@ -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")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user