@@ -58,7 +58,7 @@ func TestAPIMergePullWIP(t *testing.T) {
58
58
session .MakeRequest (t , req , http .StatusMethodNotAllowed )
59
59
}
60
60
61
- func TestAPICreatePullSuccess1 (t * testing.T ) {
61
+ func TestAPICreatePullSuccess (t * testing.T ) {
62
62
defer prepareTestEnv (t )()
63
63
repo10 := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 10 }).(* models.Repository )
64
64
// repo10 have code, pulls units.
@@ -78,7 +78,7 @@ func TestAPICreatePullSuccess1(t *testing.T) {
78
78
session .MakeRequest (t , req , 201 )
79
79
}
80
80
81
- func TestAPICreatePullSuccess2 (t * testing.T ) {
81
+ func TestAPIEditPull (t * testing.T ) {
82
82
defer prepareTestEnv (t )()
83
83
repo10 := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 10 }).(* models.Repository )
84
84
owner10 := models .AssertExistsAndLoadBean (t , & models.User {ID : repo10 .OwnerID }).(* models.User )
@@ -90,6 +90,21 @@ func TestAPICreatePullSuccess2(t *testing.T) {
90
90
Base : "master" ,
91
91
Title : "create a success pr" ,
92
92
})
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 )
93
105
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 )
95
110
}
0 commit comments