@@ -58,7 +58,7 @@ func TestAPIMergePullWIP(t *testing.T) {
5858 session .MakeRequest (t , req , http .StatusMethodNotAllowed )
5959}
6060
61- func TestAPICreatePullSuccess1 (t * testing.T ) {
61+ func TestAPICreatePullSuccess (t * testing.T ) {
6262 defer prepareTestEnv (t )()
6363 repo10 := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 10 }).(* models.Repository )
6464 // repo10 have code, pulls units.
@@ -78,7 +78,7 @@ func TestAPICreatePullSuccess1(t *testing.T) {
7878 session .MakeRequest (t , req , 201 )
7979}
8080
81- func TestAPICreatePullSuccess2 (t * testing.T ) {
81+ func TestAPIEditPull (t * testing.T ) {
8282 defer prepareTestEnv (t )()
8383 repo10 := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 10 }).(* models.Repository )
8484 owner10 := models .AssertExistsAndLoadBean (t , & models.User {ID : repo10 .OwnerID }).(* models.User )
@@ -90,6 +90,21 @@ func TestAPICreatePullSuccess2(t *testing.T) {
9090 Base : "master" ,
9191 Title : "create a success pr" ,
9292 })
93+ pull := new (api.PullRequest )
94+ resp := session .MakeRequest (t , req , 201 )
95+ DecodeJSON (t , resp , pull )
96+ assert .EqualValues (t , "master" , pull .Base .Name )
97+
98+ 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 {
99+ Base : "feature/1" ,
100+ Title : "edit a this pr" ,
101+ })
102+ resp = session .MakeRequest (t , req , 201 )
103+ DecodeJSON (t , resp , pull )
104+ assert .EqualValues (t , "feature/1" , pull .Base .Name )
93105
94- session .MakeRequest (t , req , 201 )
106+ 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 {
107+ Base : "not-exist" ,
108+ })
109+ session .MakeRequest (t , req , 404 )
95110}
0 commit comments