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

Function TestSuggestedReviewerActors

api/queries_pr_test.go:176–377  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

174}
175
176func TestSuggestedReviewerActors(t *testing.T) {
177 tests := []struct {
178 name string
179 httpStubs func(*httpmock.Registry)
180 expectedCount int
181 expectedLogins []string
182 expectedMore int
183 expectError bool
184 }{
185 {
186 name: "all sources plentiful - 5 each from cascading quota",
187 httpStubs: func(reg *httpmock.Registry) {
188 reg.Register(
189 httpmock.GraphQL(`query SuggestedReviewerActors\b`),
190 httpmock.StringResponse(mockReviewerResponse(6, 6, 6, 20, 10)))
191 },
192 expectedCount: 15,
193 expectedLogins: []string{"s1", "s2", "s3", "s4", "s5", "c1", "c2", "c3", "c4", "c5", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5"},
194 expectedMore: 30,
195 },
196 {
197 name: "few suggestions - collaborators fill gap",
198 httpStubs: func(reg *httpmock.Registry) {
199 reg.Register(
200 httpmock.GraphQL(`query SuggestedReviewerActors\b`),
201 httpmock.StringResponse(mockReviewerResponse(2, 10, 6, 50, 10)))
202 },
203 expectedCount: 15,
204 expectedLogins: []string{"s1", "s2", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5"},
205 expectedMore: 60,
206 },
207 {
208 name: "few suggestions and collaborators - teams fill gap",
209 httpStubs: func(reg *httpmock.Registry) {
210 reg.Register(
211 httpmock.GraphQL(`query SuggestedReviewerActors\b`),
212 httpmock.StringResponse(mockReviewerResponse(2, 3, 10, 3, 10)))
213 },
214 expectedCount: 15,
215 expectedLogins: []string{"s1", "s2", "c1", "c2", "c3", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8", "OWNER/team9", "OWNER/team10"},
216 expectedMore: 13,
217 },
218 {
219 name: "no suggestions or collaborators - teams only",
220 httpStubs: func(reg *httpmock.Registry) {
221 reg.Register(
222 httpmock.GraphQL(`query SuggestedReviewerActors\b`),
223 httpmock.StringResponse(mockReviewerResponse(0, 0, 10, 0, 10)))
224 },
225 expectedCount: 10, // max 15, but only 10 teams available
226 expectedLogins: []string{"OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8", "OWNER/team9", "OWNER/team10"},
227 expectedMore: 10,
228 },
229 {
230 name: "author excluded from suggestions",
231 httpStubs: func(reg *httpmock.Registry) {
232 // Custom response with author flag
233 reg.Register(

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
FromFullNameFunction · 0.92
mockReviewerResponseFunction · 0.85
newTestClientFunction · 0.85
SuggestedReviewerActorsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
LoginMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected