|
|
@ -58,7 +58,7 @@ func TestAPIMergePullWIP(t *testing.T) { |
|
|
|
session.MakeRequest(t, req, http.StatusMethodNotAllowed) |
|
|
|
session.MakeRequest(t, req, http.StatusMethodNotAllowed) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAPICreatePullSuccess1(t *testing.T) { |
|
|
|
func TestAPICreatePullSuccess(t *testing.T) { |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) |
|
|
|
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) |
|
|
|
// repo10 have code, pulls units.
|
|
|
|
// repo10 have code, pulls units.
|
|
|
@ -78,7 +78,7 @@ func TestAPICreatePullSuccess1(t *testing.T) { |
|
|
|
session.MakeRequest(t, req, 201) |
|
|
|
session.MakeRequest(t, req, 201) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestAPICreatePullSuccess2(t *testing.T) { |
|
|
|
func TestAPIEditPull(t *testing.T) { |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
defer prepareTestEnv(t)() |
|
|
|
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) |
|
|
|
repo10 := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository) |
|
|
|
owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User) |
|
|
|
owner10 := models.AssertExistsAndLoadBean(t, &models.User{ID: repo10.OwnerID}).(*models.User) |
|
|
@ -90,6 +90,21 @@ func TestAPICreatePullSuccess2(t *testing.T) { |
|
|
|
Base: "master", |
|
|
|
Base: "master", |
|
|
|
Title: "create a success pr", |
|
|
|
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) |
|
|
|
} |
|
|
|
} |
|
|
|