diff options
author | Sandro Santilli <strk@kbt.io> | 2018-01-05 11:56:52 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-01-05 12:56:52 +0200 |
commit | a192f3052ed9b59d1404fdcebf2b5c156d6d6969 (patch) | |
tree | d955279b81ab5de792158f0f131a23a7837c1e57 /integrations | |
parent | ce7ae17b81220434af13fd048e44899bbd7d9e72 (diff) | |
download | gitea-a192f3052ed9b59d1404fdcebf2b5c156d6d6969.tar.gz gitea-a192f3052ed9b59d1404fdcebf2b5c156d6d6969.zip |
Serve pull request .diff files (#3293)
* Serve pull request .diff files
Closes #3259
* Add test for pull request redirection and .diff access
* Typo
* There's no need to test for pr.BaseRepo being nil after calling GetBaseRepo
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/pull_create_test.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/integrations/pull_create_test.go b/integrations/pull_create_test.go index c392ecc18d..00a23a29e0 100644 --- a/integrations/pull_create_test.go +++ b/integrations/pull_create_test.go @@ -39,8 +39,6 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo, branch strin }) resp = session.MakeRequest(t, req, http.StatusFound) - //TODO check the redirected URL - return resp } @@ -49,5 +47,16 @@ func TestPullCreate(t *testing.T) { session := loginUser(t, "user1") testRepoFork(t, session, "user2", "repo1", "user1", "repo1") testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n") - testPullCreate(t, session, "user1", "repo1", "master") + resp := testPullCreate(t, session, "user1", "repo1", "master") + + // check the redirected URL + url := resp.HeaderMap.Get("Location") + assert.Regexp(t, "^/user2/repo1/pulls/[0-9]*$", url) + + // check .diff can be accessed and matches performed change + req := NewRequest(t, "GET", url+".diff") + resp = session.MakeRequest(t, req, http.StatusOK) + assert.Regexp(t, "\\+Hello, World \\(Edited\\)", resp.Body) + assert.Regexp(t, "^diff", resp.Body) + assert.NotRegexp(t, "diff.*diff", resp.Body) // not two diffs, just one } |