@@ -296,25 +296,25 @@ func TestAPIPullReviewRequest(t *testing.T) {
296296 user38Session := loginUser (t , "user38" )
297297 user38Token := getTokenForLoggedInUser (t , user38Session , auth_model .AccessTokenScopeWriteRepository )
298298 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" },
300300 }).AddTokenAuth (user38Token )
301301 MakeRequest (t , req , http .StatusCreated )
302302
303303 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" },
305305 }).AddTokenAuth (user38Token )
306306 MakeRequest (t , req , http .StatusNoContent )
307307
308308 // the poster of the PR can add/remove a review request
309309 user39Session := loginUser (t , "user39" )
310310 user39Token := getTokenForLoggedInUser (t , user39Session , auth_model .AccessTokenScopeWriteRepository )
311311 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 " },
313313 }).AddTokenAuth (user39Token )
314314 MakeRequest (t , req , http .StatusCreated )
315315
316316 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 " },
318318 }).AddTokenAuth (user39Token )
319319 MakeRequest (t , req , http .StatusNoContent )
320320
@@ -332,14 +332,20 @@ func TestAPIPullReviewRequest(t *testing.T) {
332332 }).AddTokenAuth (user39Token ) // user39 is from a team with read permission on pull requests unit
333333 MakeRequest (t , req , http .StatusNoContent )
334334
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+
335341 // Test team review request
336342 pullIssue12 := unittest .AssertExistsAndLoadBean (t , & issues_model.Issue {ID : 12 })
337343 assert .NoError (t , pullIssue12 .LoadAttributes (db .DefaultContext ))
338344 repo3 := unittest .AssertExistsAndLoadBean (t , & repo_model.Repository {ID : pullIssue12 .RepoID })
339345
340346 // Test add Team Review Request
341347 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 " },
343349 }).AddTokenAuth (token )
344350 MakeRequest (t , req , http .StatusCreated )
345351
@@ -353,7 +359,7 @@ func TestAPIPullReviewRequest(t *testing.T) {
353359 req = NewRequestWithJSON (t , http .MethodPost , fmt .Sprintf ("/api/v1/repos/%s/%s/pulls/%d/requested_reviewers" , repo3 .OwnerName , repo3 .Name , pullIssue12 .Index ), & api.PullReviewRequestOptions {
354360 TeamReviewers : []string {"not_exist_team" },
355361 }).AddTokenAuth (token )
356- MakeRequest (t , req , http .StatusNotFound )
362+ MakeRequest (t , req , http .StatusUnprocessableEntity )
357363
358364 // Test Remove team Review Request
359365 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