Add TeamReviewers flag to RepoMetadataInput
Introduces a TeamReviewers boolean to RepoMetadataInput to control whether team reviewers are fetched. Updates RepoMetadata logic to only fetch teams if both Reviewers and TeamReviewers are true. Adds tests to verify correct behavior when TeamReviewers is false.
This commit is contained in:
parent
b2348f8386
commit
449920b40f
2 changed files with 45 additions and 7 deletions
|
|
@ -919,6 +919,7 @@ type RepoMetadataInput struct {
|
|||
Assignees bool
|
||||
ActorAssignees bool
|
||||
Reviewers bool
|
||||
TeamReviewers bool
|
||||
Labels bool
|
||||
ProjectsV1 bool
|
||||
ProjectsV2 bool
|
||||
|
|
@ -964,7 +965,7 @@ func RepoMetadata(client *Client, repo ghrepo.Interface, input RepoMetadataInput
|
|||
}
|
||||
}
|
||||
|
||||
if input.Reviewers {
|
||||
if input.Reviewers && input.TeamReviewers {
|
||||
g.Go(func() error {
|
||||
teams, err := OrganizationTeams(client, repo)
|
||||
// TODO: better detection of non-org repos
|
||||
|
|
|
|||
|
|
@ -42,12 +42,13 @@ func Test_RepoMetadata(t *testing.T) {
|
|||
|
||||
repo, _ := ghrepo.FromFullName("OWNER/REPO")
|
||||
input := RepoMetadataInput{
|
||||
Assignees: true,
|
||||
Reviewers: true,
|
||||
Labels: true,
|
||||
ProjectsV1: true,
|
||||
ProjectsV2: true,
|
||||
Milestones: true,
|
||||
Assignees: true,
|
||||
Reviewers: true,
|
||||
TeamReviewers: true,
|
||||
Labels: true,
|
||||
ProjectsV1: true,
|
||||
ProjectsV2: true,
|
||||
Milestones: true,
|
||||
}
|
||||
|
||||
http.Register(
|
||||
|
|
@ -213,6 +214,42 @@ func Test_RepoMetadata(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_RepoMetadataTeams(t *testing.T) {
|
||||
// Test that RepoMetadata only fetches teams if the input specifies it
|
||||
http := &httpmock.Registry{}
|
||||
client := newTestClient(http)
|
||||
repo, _ := ghrepo.FromFullName("OWNER/REPO")
|
||||
input := RepoMetadataInput{
|
||||
Reviewers: true,
|
||||
TeamReviewers: false,
|
||||
}
|
||||
|
||||
http.Register(
|
||||
httpmock.GraphQL(`query RepositoryAssignableUsers\b`),
|
||||
httpmock.StringResponse(`
|
||||
{ "data": { "repository": { "assignableUsers": {
|
||||
"nodes": [
|
||||
{ "login": "hubot", "id": "HUBOTID" },
|
||||
{ "login": "MonaLisa", "id": "MONAID" }
|
||||
],
|
||||
"pageInfo": { "hasNextPage": false }
|
||||
} } } }
|
||||
`))
|
||||
|
||||
http.Register(
|
||||
httpmock.GraphQL(`query UserCurrent\b`),
|
||||
httpmock.StringResponse(`
|
||||
{ "data": { "viewer": { "login": "monalisa" } } }
|
||||
`))
|
||||
|
||||
_, err := RepoMetadata(client, repo, input)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func Test_ProjectNamesToPaths(t *testing.T) {
|
||||
t.Run("when projectsV1 is supported, requests them", func(t *testing.T) {
|
||||
http := &httpmock.Registry{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue