diff options
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) +} |