MCPcopy Create free account
hub / github.com/cli/cli / mockReviewerResponse

Function mockReviewerResponse

api/queries_pr_test.go:146–174  ·  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

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

Callers 1

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected