aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorqwerty287 <80460567+qwerty287@users.noreply.github.com>2024-02-26 03:39:01 +0100
committerGitHub <noreply@github.com>2024-02-26 02:39:01 +0000
commit65952417a81631ee879d4d29ad798cbb6445fa7e (patch)
tree97c2b95929620102021b1e6c4be7973d6dd63041 /tests
parentf38888bc7834899777bda1a271e166d3836524cf (diff)
downloadgitea-65952417a81631ee879d4d29ad798cbb6445fa7e.tar.gz
gitea-65952417a81631ee879d4d29ad798cbb6445fa7e.zip
Add API to get PR by base/head (#29242)
Closes https://github.com/go-gitea/gitea/issues/16289 Add a new API `/repos/{owner}/{repo}/pulls/{base}/{head}` to get a PR by its base and head branch.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_pull_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/integration/api_pull_test.go b/tests/integration/api_pull_test.go
index 33cc826e5e..92931c5699 100644
--- a/tests/integration/api_pull_test.go
+++ b/tests/integration/api_pull_test.go
@@ -61,6 +61,27 @@ func TestAPIViewPulls(t *testing.T) {
}
}
+func TestAPIViewPullsByBaseHead(t *testing.T) {
+ defer tests.PrepareTestEnv(t)()
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
+
+ ctx := NewAPITestContext(t, "user2", repo.Name, auth_model.AccessTokenScopeReadRepository)
+
+ req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/pulls/master/branch2", owner.Name, repo.Name).
+ AddTokenAuth(ctx.Token)
+ resp := ctx.Session.MakeRequest(t, req, http.StatusOK)
+
+ pull := &api.PullRequest{}
+ DecodeJSON(t, resp, pull)
+ assert.EqualValues(t, 3, pull.Index)
+ assert.EqualValues(t, 2, pull.ID)
+
+ req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/pulls/master/branch-not-exist", owner.Name, repo.Name).
+ AddTokenAuth(ctx.Token)
+ ctx.Session.MakeRequest(t, req, http.StatusNotFound)
+}
+
// TestAPIMergePullWIP ensures that we can't merge a WIP pull request
func TestAPIMergePullWIP(t *testing.T) {
defer tests.PrepareTestEnv(t)()