aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_pull_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-06-07 21:13:40 +0200
committerGitHub <noreply@github.com>2020-06-07 20:13:40 +0100
commit5814079bf5fd2369f8720a94128533bad21d1b17 (patch)
treeadfb71874aae1402af740d5daf2d2599730cbf5d /integrations/api_pull_test.go
parent880ae454db47b7a736024df230d115f83a108b02 (diff)
downloadgitea-5814079bf5fd2369f8720a94128533bad21d1b17.tar.gz
gitea-5814079bf5fd2369f8720a94128533bad21d1b17.zip
Add option to API to update PullRequest base branch (#11666)
* EditPull: add option to change base Close #11552
Diffstat (limited to 'integrations/api_pull_test.go')
-rw-r--r--integrations/api_pull_test.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/integrations/api_pull_test.go b/integrations/api_pull_test.go
index 9e22be5755..61daf917ff 100644
--- a/integrations/api_pull_test.go
+++ b/integrations/api_pull_test.go
@@ -58,7 +58,7 @@ func TestAPIMergePullWIP(t *testing.T) {
session.MakeRequest(t, req, http.StatusMethodNotAllowed)
}
-func TestAPICreatePullSuccess1(t *testing.T) {
+func TestAPICreatePullSuccess(t *testing.T) {
defer prepareTestEnv(t)()
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
// repo10 have code, pulls units.
@@ -78,7 +78,7 @@ func TestAPICreatePullSuccess1(t *testing.T) {
session.MakeRequest(t, req, 201)
}
-func TestAPICreatePullSuccess2(t *testing.T) {
+func TestAPIEditPull(t *testing.T) {
defer prepareTestEnv(t)()
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User)
@@ -90,6 +90,21 @@ func TestAPICreatePullSuccess2(t *testing.T) {
Base: "master",
Title: "create a success pr",
})
+ pull := new(api.PullRequest)
+ resp := session.MakeRequest(t, req, 201)
+ DecodeJSON(t, resp, pull)
+ assert.EqualValues(t, "master", pull.Base.Name)
+
+ req = NewRequestWithJSON(t, http.MethodPatch, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d?token=%s", owner10.Name, repo10.Name, pull.Index, token), &api.EditPullRequestOption{
+ Base: "feature/1",
+ Title: "edit a this pr",
+ })
+ resp = session.MakeRequest(t, req, 201)
+ DecodeJSON(t, resp, pull)
+ assert.EqualValues(t, "feature/1", pull.Base.Name)
- session.MakeRequest(t, req, 201)
+ req = NewRequestWithJSON(t, http.MethodPatch, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d?token=%s", owner10.Name, repo10.Name, pull.Index, token), &api.EditPullRequestOption{
+ Base: "not-exist",
+ })
+ session.MakeRequest(t, req, 404)
}