@@ -296,25 +296,25 @@ func TestAPIPullReviewRequest(t *testing.T) {
296
296
user38Session := loginUser (t , "user38" )
297
297
user38Token := getTokenForLoggedInUser (t , user38Session , auth_model .AccessTokenScopeWriteRepository )
298
298
req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , pull21Repo .OwnerName , pull21Repo .Name , pullIssue21 .Index ), & api.PullReviewRequestOptions {
299
- Reviewers : []string {"user4 @example.com" },
299
+ Reviewers : []string {"user40 @example.com" },
300
300
}).AddTokenAuth (user38Token )
301
301
MakeRequest (t , req , http .StatusCreated )
302
302
303
303
req = NewRequestWithJSON (t , http .MethodDelete , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , pull21Repo .OwnerName , pull21Repo .Name , pullIssue21 .Index ), & api.PullReviewRequestOptions {
304
- Reviewers : []string {"user4 @example.com" },
304
+ Reviewers : []string {"user40 @example.com" },
305
305
}).AddTokenAuth (user38Token )
306
306
MakeRequest (t , req , http .StatusNoContent )
307
307
308
308
// the poster of the PR can add/remove a review request
309
309
user39Session := loginUser (t , "user39" )
310
310
user39Token := getTokenForLoggedInUser (t , user39Session , auth_model .AccessTokenScopeWriteRepository )
311
311
req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , pull21Repo .OwnerName , pull21Repo .Name , pullIssue21 .Index ), & api.PullReviewRequestOptions {
312
- Reviewers : []string {"user8 " },
312
+ Reviewers : []string {"user38 " },
313
313
}).AddTokenAuth (user39Token )
314
314
MakeRequest (t , req , http .StatusCreated )
315
315
316
316
req = NewRequestWithJSON (t , http .MethodDelete , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , pull21Repo .OwnerName , pull21Repo .Name , pullIssue21 .Index ), & api.PullReviewRequestOptions {
317
- Reviewers : []string {"user8 " },
317
+ Reviewers : []string {"user38 " },
318
318
}).AddTokenAuth (user39Token )
319
319
MakeRequest (t , req , http .StatusNoContent )
320
320
@@ -332,14 +332,20 @@ func TestAPIPullReviewRequest(t *testing.T) {
332
332
}).AddTokenAuth (user39Token ) // user39 is from a team with read permission on pull requests unit
333
333
MakeRequest (t , req , http .StatusNoContent )
334
334
335
+ // user8 is not a reviewer, so this will return 422
336
+ req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , pull22Repo .OwnerName , pull22Repo .Name , pullIssue22 .Index ), & api.PullReviewRequestOptions {
337
+ Reviewers : []string {"user8" },
338
+ }).AddTokenAuth (user39Token ) // user39 is from a team with read permission on pull requests unit
339
+ MakeRequest (t , req , http .StatusUnprocessableEntity )
340
+
335
341
// Test team review request
336
342
pullIssue12 := unittest .AssertExistsAndLoadBean (t , & issues_model.Issue {ID : 12 })
337
343
assert .NoError (t , pullIssue12 .LoadAttributes (db .DefaultContext ))
338
344
repo3 := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : pullIssue12 .RepoID })
339
345
340
346
// Test add Team Review Request
341
347
req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , repo3 .OwnerName , repo3 .Name , pullIssue12 .Index ), & api.PullReviewRequestOptions {
342
- TeamReviewers : []string {"team1" , "owners " },
348
+ TeamReviewers : []string {"team1" , "Owners " },
343
349
}).AddTokenAuth (token )
344
350
MakeRequest (t , req , http .StatusCreated )
345
351
@@ -353,7 +359,7 @@ func TestAPIPullReviewRequest(t *testing.T) {
353
359
req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , repo3 .OwnerName , repo3 .Name , pullIssue12 .Index ), & api.PullReviewRequestOptions {
354
360
TeamReviewers : []string {"not_exist_team" },
355
361
}).AddTokenAuth (token )
356
- MakeRequest (t , req , http .StatusNotFound )
362
+ MakeRequest (t , req , http .StatusUnprocessableEntity )
357
363
358
364
// Test Remove team Review Request
359
365
req = NewRequestWithJSON (t , http .MethodDelete , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , repo3 .OwnerName , repo3 .Name , pullIssue12 .Index ), & api.PullReviewRequestOptions {
0 commit comments