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

Function TestSuggestedReviewerActorsForRepo

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

Source from the content-addressed store, hash-verified

417}
418
419func TestSuggestedReviewerActorsForRepo(t *testing.T) {
420 tests := []struct {
421 name string
422 httpStubs func(*httpmock.Registry)
423 expectedCount int
424 expectedLogins []string
425 expectedMore int
426 expectError bool
427 }{
428 {
429 name: "both sources plentiful - 5 each from cascading quota",
430 httpStubs: func(reg *httpmock.Registry) {
431 reg.Register(
432 httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`),
433 httpmock.StringResponse(mockReviewerResponseForRepo(6, 6, 20, 10)))
434 },
435 expectedCount: 10,
436 expectedLogins: []string{"c1", "c2", "c3", "c4", "c5", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5"},
437 expectedMore: 30,
438 },
439 {
440 name: "few collaborators - teams fill gap",
441 httpStubs: func(reg *httpmock.Registry) {
442 reg.Register(
443 httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`),
444 httpmock.StringResponse(mockReviewerResponseForRepo(2, 10, 2, 15)))
445 },
446 expectedCount: 10,
447 expectedLogins: []string{"c1", "c2", "OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8"},
448 expectedMore: 17,
449 },
450 {
451 name: "no collaborators - teams only",
452 httpStubs: func(reg *httpmock.Registry) {
453 reg.Register(
454 httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`),
455 httpmock.StringResponse(mockReviewerResponseForRepo(0, 10, 0, 20)))
456 },
457 expectedCount: 10,
458 expectedLogins: []string{"OWNER/team1", "OWNER/team2", "OWNER/team3", "OWNER/team4", "OWNER/team5", "OWNER/team6", "OWNER/team7", "OWNER/team8", "OWNER/team9", "OWNER/team10"},
459 expectedMore: 20,
460 },
461 {
462 name: "personal repo - no organization teams",
463 httpStubs: func(reg *httpmock.Registry) {
464 reg.Register(
465 httpmock.GraphQL(`query SuggestedReviewerActorsForRepo\b`),
466 httpmock.StringResponse(`{
467 "data": {
468 "repository": {
469 "pullRequests": {"nodes": []},
470 "owner": {"__typename": "User"},
471 "collaborators": {"nodes": [{"login": "c1", "name": "C1"}]},
472 "collaboratorsTotalCount": {"totalCount": 3}
473 }
474 }
475 }`))
476 },

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected