diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-05-08 01:20:23 +0800 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2019-05-07 13:20:23 -0400 |
commit | 9f18b231295a6282111a1f058f0c973da50b5fd4 (patch) | |
tree | ea90521aba7a1ca52c55cb61c6cb898b8d98c7f8 /integrations/api_pull_test.go | |
parent | 9139f35ff62927d23ee7a590a0987e8c12127bea (diff) | |
download | gitea-9f18b231295a6282111a1f058f0c973da50b5fd4.tar.gz gitea-9f18b231295a6282111a1f058f0c973da50b5fd4.zip |
Fix 404 when send pull request some situation (#6871)
Diffstat (limited to 'integrations/api_pull_test.go')
-rw-r--r-- | integrations/api_pull_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/integrations/api_pull_test.go b/integrations/api_pull_test.go index c416fee8ba..c378e563bd 100644 --- a/integrations/api_pull_test.go +++ b/integrations/api_pull_test.go @@ -56,3 +56,39 @@ func TestAPIMergePullWIP(t *testing.T) { session.MakeRequest(t, req, http.StatusMethodNotAllowed) } + +func TestAPICreatePullSuccess1(t *testing.T) { + prepareTestEnv(t) + repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) + // repo10 have code, pulls units. + repo11 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 11}).(*models.Repository) + // repo11 only have code unit but should still create pulls + owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User) + owner11 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo11.OwnerID}).(*models.User) + + session := loginUser(t, owner11.Name) + token := getTokenForLoggedInUser(t, session) + req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls?token=%s", owner10.Name, repo10.Name, token), &api.CreatePullRequestOption{ + Head: fmt.Sprintf("%s:master", owner11.Name), + Base: "master", + Title: "create a failure pr", + }) + + session.MakeRequest(t, req, 201) +} + +func TestAPICreatePullSuccess2(t *testing.T) { + prepareTestEnv(t) + repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) + owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User) + + session := loginUser(t, owner10.Name) + token := getTokenForLoggedInUser(t, session) + req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls?token=%s", owner10.Name, repo10.Name, token), &api.CreatePullRequestOption{ + Head: "develop", + Base: "master", + Title: "create a success pr", + }) + + session.MakeRequest(t, req, 201) +} |