summaryrefslogtreecommitdiffstats
path: root/integrations/pull_update_test.go
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-08-05 04:55:22 +0800
committerGitHub <noreply@github.com>2020-08-04 21:55:22 +0100
commit8a6790b2aa07fa006d0338669e1da6134a58e313 (patch)
tree3026006db62060a278a028764396d0dd41ef9526 /integrations/pull_update_test.go
parente61c09ed7331e6ea72e4d9f08c0490713598942d (diff)
downloadgitea-8a6790b2aa07fa006d0338669e1da6134a58e313.tar.gz
gitea-8a6790b2aa07fa006d0338669e1da6134a58e313.zip
Add API to update pr headBranch (#12419)
* [API] Add update pr headBranch api Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'integrations/pull_update_test.go')
-rw-r--r--integrations/pull_update_test.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/integrations/pull_update_test.go b/integrations/pull_update_test.go
index 484390001c..2dc966316e 100644
--- a/integrations/pull_update_test.go
+++ b/integrations/pull_update_test.go
@@ -5,7 +5,7 @@
package integrations
import (
- "fmt"
+ "net/http"
"net/url"
"testing"
"time"
@@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestPullUpdate(t *testing.T) {
+func TestAPIPullUpdate(t *testing.T) {
onGiteaRun(t, func(t *testing.T, giteaURL *url.URL) {
//Create PR to test
user := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
@@ -31,17 +31,19 @@ func TestPullUpdate(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, 1, diffCount.Behind)
assert.EqualValues(t, 1, diffCount.Ahead)
+ assert.NoError(t, pr.LoadBaseRepo())
+ assert.NoError(t, pr.LoadIssue())
- message := fmt.Sprintf("Merge branch '%s' into %s", pr.BaseBranch, pr.HeadBranch)
- err = pull_service.Update(pr, user, message)
- assert.NoError(t, err)
+ session := loginUser(t, "user2")
+ token := getTokenForLoggedInUser(t, session)
+ req := NewRequestf(t, "POST", "/api/v1/repos/%s/%s/pulls/%d/update?token="+token, pr.BaseRepo.OwnerName, pr.BaseRepo.Name, pr.Issue.Index)
+ session.MakeRequest(t, req, http.StatusOK)
//Test GetDiverging after update
diffCount, err = pull_service.GetDiverging(pr)
assert.NoError(t, err)
assert.EqualValues(t, 0, diffCount.Behind)
assert.EqualValues(t, 2, diffCount.Ahead)
-
})
}