Skip to content

Commit e8c2c92

Browse files
committed
Add test for pull request redirection and .diff access
1 parent 1ce38a4 commit e8c2c92

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

integrations/pull_create_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin
3939
})
4040
resp = session.MakeRequest(t, req, http.StatusFound)
4141

42-
//TODO check the redirected URL
43-
4442
return resp
4543
}
4644

@@ -49,5 +47,16 @@ func TestPullCreate(t *testing.T) {
4947
session := loginUser(t, "user1")
5048
testRepoFork(t, session, "user2", "repo1", "user1", "repo1")
5149
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
52-
testPullCreate(t, session, "user1", "repo1", "master")
50+
resp := testPullCreate(t, session, "user1", "repo1", "master")
51+
52+
// check the redirected URL
53+
url := resp.HeaderMap.Get("Location")
54+
assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url)
55+
56+
// check .diff can be accessed and matches performed change
57+
req := NewRequest(t, "GET", url+".diff")
58+
resp = session.MakeRequest(t, req, http.StatusOK)
59+
assert.Regexp(t, "\\+Hello, World \\(Edited\\)", resp.Body)
60+
assert.Regexp(t, "^diff", resp.Body)
61+
assert.NotRegexp(t, "diff.*diff", resp.Body) // not two diffs, just one
5362
}

0 commit comments

Comments
 (0)