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

Function TestSuggestedReviewerActors

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

Source from the content-addressed store, hash-verified

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