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

Function mockReviewerResponse

api/queries_pr_test.go:145–173  ·  view source on GitHub ↗

mockReviewerResponse generates a GraphQL response for SuggestedReviewerActors tests. It creates suggestions (s1, s2...), collaborators (c1, c2...), and teams (team1, team2...). totalCollabs and totalTeams set the unfiltered TotalCount fields (for "more results" calculation).

(suggestions, collabs, teams, totalCollabs, totalTeams int)

Source from the content-addressed store, hash-verified

143// It creates suggestions (s1, s2...), collaborators (c1, c2...), and teams (team1, team2...).
144// totalCollabs and totalTeams set the unfiltered TotalCount fields (for "more results" calculation).
145func mockReviewerResponse(suggestions, collabs, teams, totalCollabs, totalTeams int) string {
146 var suggestionNodes, collabNodes, teamNodes []string
147
148 for i := 1; i <= suggestions; i++ {
149 suggestionNodes = append(suggestionNodes,
150 fmt.Sprintf(`{"isAuthor": false, "reviewer": {"__typename": "User", "login": "s%d", "name": "S%d"}}`, i, i))
151 }
152 for i := 1; i <= collabs; i++ {
153 collabNodes = append(collabNodes,
154 fmt.Sprintf(`{"login": "c%d", "name": "C%d"}`, i, i))
155 }
156 for i := 1; i <= teams; i++ {
157 teamNodes = append(teamNodes,
158 fmt.Sprintf(`{"slug": "team%d"}`, i))
159 }
160
161 return fmt.Sprintf(`{
162 "data": {
163 "node": {"author": {"login": "testauthor"}, "suggestedReviewerActors": {"nodes": [%s]}},
164 "repository": {
165 "owner": {"__typename": "Organization", "teams": {"nodes": [%s]}, "teamsTotalCount": {"totalCount": %d}},
166 "collaborators": {"nodes": [%s]},
167 "collaboratorsTotalCount": {"totalCount": %d}
168 }
169 }
170 }`, strings.Join(suggestionNodes, ","),
171 strings.Join(teamNodes, ","), totalTeams,
172 strings.Join(collabNodes, ","), totalCollabs)
173}
174
175func TestSuggestedReviewerActors(t *testing.T) {
176 tests := []struct {

Callers 1

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected