mockReviewerResponseForRepoWithCopilot generates a GraphQL response for SuggestedReviewerActorsForRepo tests. If copilotAvailable is true, includes Copilot in the first open PR's suggested reviewers.
(collabs, teams, totalCollabs, totalTeams int, copilotAvailable bool)
| 384 | // mockReviewerResponseForRepoWithCopilot generates a GraphQL response for SuggestedReviewerActorsForRepo tests. |
| 385 | // If copilotAvailable is true, includes Copilot in the first open PR's suggested reviewers. |
| 386 | func mockReviewerResponseForRepoWithCopilot(collabs, teams, totalCollabs, totalTeams int, copilotAvailable bool) string { |
| 387 | var collabNodes, teamNodes []string |
| 388 | |
| 389 | for i := 1; i <= collabs; i++ { |
| 390 | collabNodes = append(collabNodes, |
| 391 | fmt.Sprintf(`{"login": "c%d", "name": "C%d"}`, i, i)) |
| 392 | } |
| 393 | for i := 1; i <= teams; i++ { |
| 394 | teamNodes = append(teamNodes, |
| 395 | fmt.Sprintf(`{"slug": "team%d"}`, i)) |
| 396 | } |
| 397 | |
| 398 | pullRequestsJSON := `"pullRequests": {"nodes": []}` |
| 399 | if copilotAvailable { |
| 400 | pullRequestsJSON = `"pullRequests": {"nodes": [{"suggestedReviewerActors": {"nodes": [{"reviewer": {"__typename": "Bot", "login": "copilot-pull-request-reviewer"}}]}}]}` |
| 401 | } |
| 402 | |
| 403 | return fmt.Sprintf(`{ |
| 404 | "data": { |
| 405 | "viewer": {"login": "testuser"}, |
| 406 | "repository": { |
| 407 | %s, |
| 408 | "owner": {"__typename": "Organization", "teams": {"nodes": [%s]}, "teamsTotalCount": {"totalCount": %d}}, |
| 409 | "collaborators": {"nodes": [%s]}, |
| 410 | "collaboratorsTotalCount": {"totalCount": %d} |
| 411 | } |
| 412 | } |
| 413 | }`, pullRequestsJSON, |
| 414 | strings.Join(teamNodes, ","), totalTeams, |
| 415 | strings.Join(collabNodes, ","), totalCollabs) |
| 416 | } |
| 417 | |
| 418 | func TestSuggestedReviewerActorsForRepo(t *testing.T) { |
| 419 | tests := []struct { |
no test coverage detected