|
|
@ -4,6 +4,7 @@ |
|
|
|
package integration |
|
|
|
package integration |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"net/http/httptest" |
|
|
|
"net/http/httptest" |
|
|
|
"net/url" |
|
|
|
"net/url" |
|
|
@ -57,6 +58,30 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSel |
|
|
|
return resp |
|
|
|
return resp |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func testPullCreateDirectly(t *testing.T, session *TestSession, baseRepoOwner, baseRepoName, baseBranch, headRepoOwner, headRepoName, headBranch, title string) *httptest.ResponseRecorder { |
|
|
|
|
|
|
|
headCompare := headBranch |
|
|
|
|
|
|
|
if headRepoOwner != "" { |
|
|
|
|
|
|
|
if headRepoName != "" { |
|
|
|
|
|
|
|
headCompare = fmt.Sprintf("%s/%s:%s", headRepoOwner, headRepoName, headBranch) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
headCompare = fmt.Sprintf("%s:%s", headRepoOwner, headBranch) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
req := NewRequest(t, "GET", fmt.Sprintf("/%s/%s/compare/%s...%s", baseRepoOwner, baseRepoName, baseBranch, headCompare)) |
|
|
|
|
|
|
|
resp := session.MakeRequest(t, req, http.StatusOK) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Submit the form for creating the pull
|
|
|
|
|
|
|
|
htmlDoc := NewHTMLParser(t, resp.Body) |
|
|
|
|
|
|
|
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action") |
|
|
|
|
|
|
|
assert.True(t, exists, "The template has changed") |
|
|
|
|
|
|
|
req = NewRequestWithValues(t, "POST", link, map[string]string{ |
|
|
|
|
|
|
|
"_csrf": htmlDoc.GetCSRF(), |
|
|
|
|
|
|
|
"title": title, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
resp = session.MakeRequest(t, req, http.StatusOK) |
|
|
|
|
|
|
|
return resp |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestPullCreate(t *testing.T) { |
|
|
|
func TestPullCreate(t *testing.T) { |
|
|
|
onGiteaRun(t, func(t *testing.T, u *url.URL) { |
|
|
|
onGiteaRun(t, func(t *testing.T, u *url.URL) { |
|
|
|
session := loginUser(t, "user1") |
|
|
|
session := loginUser(t, "user1") |
|
|
|