Skip to content

Commit b76cd74

Browse files
committed
fix test
1 parent 4e3d89d commit b76cd74

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/integration/pull_create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"testing"
1313

14+
"code.gitea.io/gitea/modules/test"
1415
"code.gitea.io/gitea/tests"
1516

1617
"github.com/stretchr/testify/assert"
@@ -39,8 +40,7 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch, titl
3940
"_csrf": htmlDoc.GetCSRF(),
4041
"title": title,
4142
})
42-
resp = session.MakeRequest(t, req, http.StatusSeeOther)
43-
43+
resp = session.MakeRequest(t, req, http.StatusOK)
4444
return resp
4545
}
4646

@@ -52,7 +52,7 @@ func TestPullCreate(t *testing.T) {
5252
resp := testPullCreate(t, session, "user1", "repo1", "master", "This is a pull title")
5353

5454
// check the redirected URL
55-
url := resp.Header().Get("Location")
55+
url := test.RedirectURL(resp)
5656
assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url)
5757

5858
// check .diff can be accessed and matches performed change
@@ -80,7 +80,7 @@ func TestPullCreate_TitleEscape(t *testing.T) {
8080
resp := testPullCreate(t, session, "user1", "repo1", "master", "<i>XSS PR</i>")
8181

8282
// check the redirected URL
83-
url := resp.Header().Get("Location")
83+
url := test.RedirectURL(resp)
8484
assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url)
8585

8686
// Edit title
@@ -145,7 +145,7 @@ func TestPullBranchDelete(t *testing.T) {
145145
resp := testPullCreate(t, session, "user1", "repo1", "master1", "This is a pull title")
146146

147147
// check the redirected URL
148-
url := resp.Header().Get("Location")
148+
url := test.RedirectURL(resp)
149149
assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url)
150150
req := NewRequest(t, "GET", url)
151151
session.MakeRequest(t, req, http.StatusOK)

tests/integration/pull_merge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestCantMergeWorkInProgress(t *testing.T) {
199199

200200
resp := testPullCreate(t, session, "user1", "repo1", "master", "[wip] This is a pull title")
201201

202-
req := NewRequest(t, "GET", resp.Header().Get("Location"))
202+
req := NewRequest(t, "GET", test.RedirectURL(resp))
203203
resp = session.MakeRequest(t, req, http.StatusOK)
204204
htmlDoc := NewHTMLParser(t, resp.Body)
205205
text := strings.TrimSpace(htmlDoc.doc.Find(".merge-section > .item").Last().Text())

tests/integration/pull_status_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestPullCreate_CommitStatus(t *testing.T) {
3030
"title": "pull request from status1",
3131
},
3232
)
33-
session.MakeRequest(t, req, http.StatusSeeOther)
33+
session.MakeRequest(t, req, http.StatusOK)
3434

3535
req = NewRequest(t, "GET", "/user1/repo1/pulls")
3636
resp := session.MakeRequest(t, req, http.StatusOK)
@@ -127,7 +127,7 @@ func TestPullCreate_EmptyChangesWithDifferentCommits(t *testing.T) {
127127
"title": "pull request from status1",
128128
},
129129
)
130-
session.MakeRequest(t, req, http.StatusSeeOther)
130+
session.MakeRequest(t, req, http.StatusOK)
131131

132132
req = NewRequest(t, "GET", "/user1/repo1/pulls/1")
133133
resp := session.MakeRequest(t, req, http.StatusOK)
@@ -150,7 +150,7 @@ func TestPullCreate_EmptyChangesWithSameCommits(t *testing.T) {
150150
"title": "pull request from status1",
151151
},
152152
)
153-
session.MakeRequest(t, req, http.StatusSeeOther)
153+
session.MakeRequest(t, req, http.StatusOK)
154154
req = NewRequest(t, "GET", "/user1/repo1/pulls/1")
155155
resp := session.MakeRequest(t, req, http.StatusOK)
156156
doc := NewHTMLParser(t, resp.Body)

0 commit comments

Comments
 (0)