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

Function Test_RepoMetadata_TeamsAreConditionallyFetched

api/queries_repo_test.go:468–502  ·  view source on GitHub ↗

Test that RepoMetadata only fetches teams if the input specifies it

(t *testing.T)

Source from the content-addressed store, hash-verified

466
467// Test that RepoMetadata only fetches teams if the input specifies it
468func Test_RepoMetadata_TeamsAreConditionallyFetched(t *testing.T) {
469 http := &httpmock.Registry{}
470 client := newTestClient(http)
471 repo, _ := ghrepo.FromFullName("OWNER/REPO")
472 input := RepoMetadataInput{
473 Reviewers: true,
474 TeamReviewers: false, // Do not fetch teams
475 }
476
477 http.Register(
478 httpmock.GraphQL(`query RepositoryAssignableUsers\b`),
479 httpmock.StringResponse(`
480 { "data": { "repository": { "assignableUsers": {
481 "nodes": [
482 { "login": "hubot", "id": "HUBOTID" },
483 { "login": "MonaLisa", "id": "MONAID" }
484 ],
485 "pageInfo": { "hasNextPage": false }
486 } } } }
487 `))
488
489 http.Register(
490 httpmock.GraphQL(`query UserCurrent\b`),
491 httpmock.StringResponse(`
492 { "data": { "viewer": { "login": "monalisa" } } }
493 `))
494
495 http.Exclude(
496 t,
497 httpmock.GraphQL(`query OrganizationTeamList\b`),
498 )
499
500 _, err := RepoMetadata(client, repo, input)
501 require.NoError(t, err)
502}
503
504func Test_ProjectNamesToPaths(t *testing.T) {
505 t.Run("when projectsV1 is supported, requests them", func(t *testing.T) {

Callers

nothing calls this directly

Calls 7

RegisterMethod · 0.95
ExcludeMethod · 0.95
FromFullNameFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
newTestClientFunction · 0.85
RepoMetadataFunction · 0.85

Tested by

no test coverage detected