MCPcopy Index your code
hub / github.com/cli/cli / mockReviewerResponseForRepoWithCopilot

Function mockReviewerResponseForRepoWithCopilot

api/queries_pr_test.go:386–416  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

384// mockReviewerResponseForRepoWithCopilot generates a GraphQL response for SuggestedReviewerActorsForRepo tests.
385// If copilotAvailable is true, includes Copilot in the first open PR's suggested reviewers.
386func 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
418func TestSuggestedReviewerActorsForRepo(t *testing.T) {
419 tests := []struct {

Callers 2

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected