diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-06-19 16:25:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-19 08:25:36 +0000 |
commit | b4e4b7ad51e4c52a42eb114c9a70b4383f1871ef (patch) | |
tree | c61787edaab0b8a31ea3f852302fdb4d44821567 /tests | |
parent | c09d0b4952c351dbd9c71b9fe83c76cfd3c4f9d5 (diff) | |
download | gitea-b4e4b7ad51e4c52a42eb114c9a70b4383f1871ef.tar.gz gitea-b4e4b7ad51e4c52a42eb114c9a70b4383f1871ef.zip |
Make backend code respond correct JSON when creating PR (#25353)
Fix #25351
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/pull_create_test.go | 10 | ||||
-rw-r--r-- | tests/integration/pull_merge_test.go | 2 | ||||
-rw-r--r-- | tests/integration/pull_status_test.go | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/tests/integration/pull_create_test.go b/tests/integration/pull_create_test.go index 6e2d65ca0a..a6ee0d9dfa 100644 --- a/tests/integration/pull_create_test.go +++ b/tests/integration/pull_create_test.go @@ -11,6 +11,7 @@ import ( "strings" "testing" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" @@ -39,8 +40,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, titl "_csrf": htmlDoc.GetCSRF(), "title": title, }) - resp = session.MakeRequest(t, req, http.StatusSeeOther) - + resp = session.MakeRequest(t, req, http.StatusOK) return resp } @@ -52,7 +52,7 @@ func TestPullCreate(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title") // check the redirected URL - url := resp.Header().Get("Location") + url := test.RedirectURL(resp) assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url) // check .diff can be accessed and matches performed change @@ -80,7 +80,7 @@ func TestPullCreate_TitleEscape(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "master", "<i>XSS PR</i>") // check the redirected URL - url := resp.Header().Get("Location") + url := test.RedirectURL(resp) assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url) // Edit title @@ -145,7 +145,7 @@ func TestPullBranchDelete(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "master1", "This is a pull title") // check the redirected URL - url := resp.Header().Get("Location") + url := test.RedirectURL(resp) assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url) req := NewRequest(t, "GET", url) session.MakeRequest(t, req, http.StatusOK) diff --git a/tests/integration/pull_merge_test.go b/tests/integration/pull_merge_test.go index 8890347c36..7b7c8864c7 100644 --- a/tests/integration/pull_merge_test.go +++ b/tests/integration/pull_merge_test.go @@ -199,7 +199,7 @@ func TestCantMergeWorkInProgress(t *testing.T) { resp := testPullCreate(t, session, "user1", "repo1", "master", "[wip] This is a pull title") - req := NewRequest(t, "GET", resp.Header().Get("Location")) + req := NewRequest(t, "GET", test.RedirectURL(resp)) resp = session.MakeRequest(t, req, http.StatusOK) htmlDoc := NewHTMLParser(t, resp.Body) text := strings.TrimSpace(htmlDoc.doc.Find(".merge-section > .item").Last().Text()) diff --git a/tests/integration/pull_status_test.go b/tests/integration/pull_status_test.go index 0bdb80ecbf..6a6fd2e859 100644 --- a/tests/integration/pull_status_test.go +++ b/tests/integration/pull_status_test.go @@ -30,7 +30,7 @@ func TestPullCreate_CommitStatus(t *testing.T) { "title": "pull request from status1", }, ) - session.MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusOK) req = NewRequest(t, "GET", "/user1/repo1/pulls") resp := session.MakeRequest(t, req, http.StatusOK) @@ -127,7 +127,7 @@ func TestPullCreate_EmptyChangesWithDifferentCommits(t *testing.T) { "title": "pull request from status1", }, ) - session.MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusOK) req = NewRequest(t, "GET", "/user1/repo1/pulls/1") resp := session.MakeRequest(t, req, http.StatusOK) @@ -150,7 +150,7 @@ func TestPullCreate_EmptyChangesWithSameCommits(t *testing.T) { "title": "pull request from status1", }, ) - session.MakeRequest(t, req, http.StatusSeeOther) + session.MakeRequest(t, req, http.StatusOK) req = NewRequest(t, "GET", "/user1/repo1/pulls/1") resp := session.MakeRequest(t, req, http.StatusOK) doc := NewHTMLParser(t, resp.Body) |