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.
This commit is contained in:
Kynan Ware 2025-07-23 09:59:20 -06:00
parent e5feda353f
commit addee16531

View file

@ -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)
}