(t *testing.T)
| 416 | } |
| 417 | |
| 418 | func TestSuggestedReviewerActorsForRepo(t *testing.T) { |
| 419 | tests := []struct { |
| 420 | name string |
| 421 | httpStubs func(*httpmock.Registry) |
| 422 | expectedCount int |
| 423 | expectedLogins []string |
| 424 | expectedMore int |
| 425 | expectError bool |
| 426 | }{ |
| 427 | { |
| 428 | name: "both sources plentiful - 5 each from cascading quota", |
| 429 | httpStubs: func(reg *httpmock.Registry) { |
| 430 | reg.Register( |
| 431 | httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`), |
| 432 | httpmock.StringResponse(mockReviewerResponseForRepo(6, 6, 20, 10))) |
| 433 | }, |
| 434 | expectedCount: 10, |
| 435 | expectedLogins: []string{"c1", "c2", "c3", "c4", "c5", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5"}, |
| 436 | expectedMore: 30, |
| 437 | }, |
| 438 | { |
| 439 | name: "few collaborators - teams fill gap", |
| 440 | httpStubs: func(reg *httpmock.Registry) { |
| 441 | reg.Register( |
| 442 | httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`), |
| 443 | httpmock.StringResponse(mockReviewerResponseForRepo(2, 10, 2, 15))) |
| 444 | }, |
| 445 | expectedCount: 10, |
| 446 | expectedLogins: []string{"c1", "c2", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8"}, |
| 447 | expectedMore: 17, |
| 448 | }, |
| 449 | { |
| 450 | name: "no collaborators - teams only", |
| 451 | httpStubs: func(reg *httpmock.Registry) { |
| 452 | reg.Register( |
| 453 | httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`), |
| 454 | httpmock.StringResponse(mockReviewerResponseForRepo(0, 10, 0, 20))) |
| 455 | }, |
| 456 | expectedCount: 10, |
| 457 | expectedLogins: []string{"OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8", "OWNER/team9", "OWNER/team10"}, |
| 458 | expectedMore: 20, |
| 459 | }, |
| 460 | { |
| 461 | name: "personal repo - no organization teams", |
| 462 | httpStubs: func(reg *httpmock.Registry) { |
| 463 | reg.Register( |
| 464 | httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`), |
| 465 | httpmock.StringResponse(`{ |
| 466 | "data": { |
| 467 | "repository": { |
| 468 | "pullRequests": {"nodes": []}, |
| 469 | "owner": {"__typename": "User"}, |
| 470 | "collaborators": {"nodes": [{"login": "c1", "name": "C1"}]}, |
| 471 | "collaboratorsTotalCount": {"totalCount": 3} |
| 472 | } |
| 473 | } |
| 474 | }`)) |
| 475 | }, |
nothing calls this directly
no test coverage detected