From addee16531fb834e7459bc9da105b0f551e5f71d Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Wed, 23 Jul 2025 09:59:20 -0600 Subject: [PATCH] Refactor and improve RepoMetadata teams test Renamed the test to clarify its purpose and added an explicit exclusion for the OrganizationTeamList GraphQL query to ensure teams are only fetched when specified. This improves test accuracy and readability. --- api/queries_repo_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/queries_repo_test.go b/api/queries_repo_test.go index 35ddceb3d..ed6c7a7fd 100644 --- a/api/queries_repo_test.go +++ b/api/queries_repo_test.go @@ -214,14 +214,14 @@ func Test_RepoMetadata(t *testing.T) { } } -func Test_RepoMetadataTeams(t *testing.T) { - // Test that RepoMetadata only fetches teams if the input specifies it +// Test that RepoMetadata only fetches teams if the input specifies it +func Test_RepoMetadata_TeamsAreConditionallyFetched(t *testing.T) { http := &httpmock.Registry{} client := newTestClient(http) repo, _ := ghrepo.FromFullName("OWNER/REPO") input := RepoMetadataInput{ Reviewers: true, - TeamReviewers: false, + TeamReviewers: false, // Do not fetch teams } http.Register( @@ -242,6 +242,11 @@ func Test_RepoMetadataTeams(t *testing.T) { { "data": { "viewer": { "login": "monalisa" } } } `)) + http.Exclude( + t, + httpmock.GraphQL(`query OrganizationTeamList\b`), + ) + _, err := RepoMetadata(client, repo, input) require.NoError(t, err) }