diff --git a/github/gen-iterators.go b/github/gen-iterators.go index 5f48a81620b..57131320674 100644 --- a/github/gen-iterators.go +++ b/github/gen-iterators.go @@ -117,6 +117,7 @@ type method struct { UseListCursorOptions bool UseListOptions bool UsePage bool + UseAfter bool TestJSON1 string TestJSON2 string TestJSON3 string @@ -206,6 +207,22 @@ func (t *templateData) hasIntPage(structName string) bool { return false } +func (t *templateData) hasStringAfter(structName string) bool { + sd, ok := t.Structs[structName] + if !ok { + return false + } + if typeStr, ok := sd.Fields["After"]; ok { + return typeStr == "string" + } + for _, embed := range sd.Embeds { + if t.hasStringAfter(embed) { + return true + } + } + return false +} + func getZeroValue(typeStr string) string { switch typeStr { case "int", "int64", "int32": @@ -303,9 +320,10 @@ func (t *templateData) processMethods(f *ast.File) error { useListCursorOptions := t.hasListCursorOptions(optsType) useListOptions := t.hasListOptions(optsType) usePage := t.hasIntPage(optsType) + useAfter := t.hasStringAfter(optsType) - if !useListCursorOptions && !useListOptions && !usePage { - logf("Skipping %s.%s: opts %s does not have ListCursorOptions, ListOptions, or Page int", recvType, fd.Name.Name, optsType) + if !useListCursorOptions && !useListOptions && !usePage && !useAfter { + logf("Skipping %s.%s: opts %s does not have ListCursorOptions, ListOptions, Page int, or After string", recvType, fd.Name.Name, optsType) continue } @@ -346,6 +364,7 @@ func (t *templateData) processMethods(f *ast.File) error { UseListCursorOptions: useListCursorOptions, UseListOptions: useListOptions, UsePage: usePage, + UseAfter: useAfter, TestJSON1: testJSON1, TestJSON2: testJSON2, TestJSON3: testJSON3, @@ -463,11 +482,16 @@ func ({{.RecvVar}} *{{.RecvType}}) {{.IterMethod}}({{.Args}}) iter.Seq2[{{.Retur break } {{.OptsName}}.ListOptions.Page = resp.NextPage - {{else}} + {{else if .UsePage}} if resp.NextPage == 0 { break } {{.OptsName}}.Page = resp.NextPage + {{else if .UseAfter}} + if resp.After == "" { + break + } + {{.OptsName}}.After = resp.After {{end -}} } } @@ -493,7 +517,7 @@ func Test{{.RecvType}}_{{.IterMethod}}(t *testing.T) { callNum++ switch callNum { case 1: - {{- if .UseListCursorOptions}} + {{- if or .UseListCursorOptions .UseAfter}} w.Header().Set("Link", ` + "`" + `; rel="next"` + "`" + `) {{else}} w.Header().Set("Link", ` + "`" + `; rel="next"` + "`" + `) diff --git a/github/github-iterators.go b/github/github-iterators.go index ddeb888747f..99c03f4e134 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -448,6 +448,37 @@ func (s *ActivityService) ListWatchersIter(ctx context.Context, owner string, re } } +// ListHookDeliveriesIter returns an iterator that paginates through all results of ListHookDeliveries. +func (s *AppsService) ListHookDeliveriesIter(ctx context.Context, opts *ListCursorOptions) iter.Seq2[*HookDelivery, error] { + return func(yield func(*HookDelivery, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCursorOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListHookDeliveries(ctx, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListInstallationRequestsIter returns an iterator that paginates through all results of ListInstallationRequests. func (s *AppsService) ListInstallationRequestsIter(ctx context.Context, opts *ListOptions) iter.Seq2[*InstallationRequest, error] { return func(yield func(*InstallationRequest, error) bool) { @@ -979,6 +1010,68 @@ func (s *EnterpriseService) ListAssignmentsIter(ctx context.Context, enterprise } } +// ListCodeSecurityConfigurationRepositoriesIter returns an iterator that paginates through all results of ListCodeSecurityConfigurationRepositories. +func (s *EnterpriseService) ListCodeSecurityConfigurationRepositoriesIter(ctx context.Context, enterprise string, configurationID int64, opts *ListCodeSecurityConfigurationRepositoriesOptions) iter.Seq2[*RepositoryAttachment, error] { + return func(yield func(*RepositoryAttachment, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCodeSecurityConfigurationRepositoriesOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListCodeSecurityConfigurationRepositories(ctx, enterprise, configurationID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListCodeSecurityConfigurationsIter returns an iterator that paginates through all results of ListCodeSecurityConfigurations. +func (s *EnterpriseService) ListCodeSecurityConfigurationsIter(ctx context.Context, enterprise string, opts *ListEnterpriseCodeSecurityConfigurationOptions) iter.Seq2[*CodeSecurityConfiguration, error] { + return func(yield func(*CodeSecurityConfiguration, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListEnterpriseCodeSecurityConfigurationOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListCodeSecurityConfigurations(ctx, enterprise, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListOrganizationCustomPropertyValuesIter returns an iterator that paginates through all results of ListOrganizationCustomPropertyValues. func (s *EnterpriseService) ListOrganizationCustomPropertyValuesIter(ctx context.Context, enterprise string, opts *ListOptions) iter.Seq2[*EnterpriseCustomPropertiesValues, error] { return func(yield func(*EnterpriseCustomPropertiesValues, error) bool) { @@ -1910,6 +2003,68 @@ func (s *OrganizationsService) ListBlockedUsersIter(ctx context.Context, org str } } +// ListCodeSecurityConfigurationRepositoriesIter returns an iterator that paginates through all results of ListCodeSecurityConfigurationRepositories. +func (s *OrganizationsService) ListCodeSecurityConfigurationRepositoriesIter(ctx context.Context, org string, configurationID int64, opts *ListCodeSecurityConfigurationRepositoriesOptions) iter.Seq2[*RepositoryAttachment, error] { + return func(yield func(*RepositoryAttachment, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCodeSecurityConfigurationRepositoriesOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListCodeSecurityConfigurationRepositories(ctx, org, configurationID, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListCodeSecurityConfigurationsIter returns an iterator that paginates through all results of ListCodeSecurityConfigurations. +func (s *OrganizationsService) ListCodeSecurityConfigurationsIter(ctx context.Context, org string, opts *ListOrgCodeSecurityConfigurationOptions) iter.Seq2[*CodeSecurityConfiguration, error] { + return func(yield func(*CodeSecurityConfiguration, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListOrgCodeSecurityConfigurationOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListCodeSecurityConfigurations(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListCredentialAuthorizationsIter returns an iterator that paginates through all results of ListCredentialAuthorizations. func (s *OrganizationsService) ListCredentialAuthorizationsIter(ctx context.Context, org string, opts *CredentialAuthorizationsListOptions) iter.Seq2[*CredentialAuthorization, error] { return func(yield func(*CredentialAuthorization, error) bool) { @@ -2034,6 +2189,37 @@ func (s *OrganizationsService) ListFineGrainedPersonalAccessTokensIter(ctx conte } } +// ListHookDeliveriesIter returns an iterator that paginates through all results of ListHookDeliveries. +func (s *OrganizationsService) ListHookDeliveriesIter(ctx context.Context, org string, id int64, opts *ListCursorOptions) iter.Seq2[*HookDelivery, error] { + return func(yield func(*HookDelivery, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCursorOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListHookDeliveries(ctx, org, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListHooksIter returns an iterator that paginates through all results of ListHooks. func (s *OrganizationsService) ListHooksIter(ctx context.Context, org string, opts *ListOptions) iter.Seq2[*Hook, error] { return func(yield func(*Hook, error) bool) { @@ -2313,6 +2499,192 @@ func (s *OrganizationsService) ListUsersAssignedToOrgRoleIter(ctx context.Contex } } +// ListOrganizationProjectFieldsIter returns an iterator that paginates through all results of ListOrganizationProjectFields. +func (s *ProjectsService) ListOrganizationProjectFieldsIter(ctx context.Context, org string, projectNumber int, opts *ListProjectsOptions) iter.Seq2[*ProjectV2Field, error] { + return func(yield func(*ProjectV2Field, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListOrganizationProjectFields(ctx, org, projectNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListOrganizationProjectItemsIter returns an iterator that paginates through all results of ListOrganizationProjectItems. +func (s *ProjectsService) ListOrganizationProjectItemsIter(ctx context.Context, org string, projectNumber int, opts *ListProjectItemsOptions) iter.Seq2[*ProjectV2Item, error] { + return func(yield func(*ProjectV2Item, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectItemsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListOrganizationProjectItems(ctx, org, projectNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListOrganizationProjectsIter returns an iterator that paginates through all results of ListOrganizationProjects. +func (s *ProjectsService) ListOrganizationProjectsIter(ctx context.Context, org string, opts *ListProjectsOptions) iter.Seq2[*ProjectV2, error] { + return func(yield func(*ProjectV2, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListOrganizationProjects(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListUserProjectFieldsIter returns an iterator that paginates through all results of ListUserProjectFields. +func (s *ProjectsService) ListUserProjectFieldsIter(ctx context.Context, user string, projectNumber int, opts *ListProjectsOptions) iter.Seq2[*ProjectV2Field, error] { + return func(yield func(*ProjectV2Field, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListUserProjectFields(ctx, user, projectNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListUserProjectItemsIter returns an iterator that paginates through all results of ListUserProjectItems. +func (s *ProjectsService) ListUserProjectItemsIter(ctx context.Context, username string, projectNumber int, opts *ListProjectItemsOptions) iter.Seq2[*ProjectV2Item, error] { + return func(yield func(*ProjectV2Item, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectItemsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListUserProjectItems(ctx, username, projectNumber, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + +// ListUserProjectsIter returns an iterator that paginates through all results of ListUserProjects. +func (s *ProjectsService) ListUserProjectsIter(ctx context.Context, username string, opts *ListProjectsOptions) iter.Seq2[*ProjectV2, error] { + return func(yield func(*ProjectV2, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListProjectsOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListUserProjects(ctx, username, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListIter returns an iterator that paginates through all results of List. func (s *PullRequestsService) ListIter(ctx context.Context, owner string, repo string, opts *PullRequestListOptions) iter.Seq2[*PullRequest, error] { return func(yield func(*PullRequest, error) bool) { @@ -3212,6 +3584,37 @@ func (s *RepositoriesService) ListForksIter(ctx context.Context, owner string, r } } +// ListHookDeliveriesIter returns an iterator that paginates through all results of ListHookDeliveries. +func (s *RepositoriesService) ListHookDeliveriesIter(ctx context.Context, owner string, repo string, id int64, opts *ListCursorOptions) iter.Seq2[*HookDelivery, error] { + return func(yield func(*HookDelivery, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCursorOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListHookDeliveries(ctx, owner, repo, id, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListHooksIter returns an iterator that paginates through all results of ListHooks. func (s *RepositoriesService) ListHooksIter(ctx context.Context, owner string, repo string, opts *ListOptions) iter.Seq2[*Hook, error] { return func(yield func(*Hook, error) bool) { @@ -3429,6 +3832,37 @@ func (s *RepositoriesService) ListReleasesIter(ctx context.Context, owner string } } +// ListRepositoryActivitiesIter returns an iterator that paginates through all results of ListRepositoryActivities. +func (s *RepositoriesService) ListRepositoryActivitiesIter(ctx context.Context, owner string, repo string, opts *ListRepositoryActivityOptions) iter.Seq2[*RepositoryActivity, error] { + return func(yield func(*RepositoryActivity, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListRepositoryActivityOptions{} + } else { + opts = Ptr(*opts) + } + + for { + items, resp, err := s.ListRepositoryActivities(ctx, owner, repo, opts) + if err != nil { + yield(nil, err) + return + } + + for _, item := range items { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListStatusesIter returns an iterator that paginates through all results of ListStatuses. func (s *RepositoriesService) ListStatusesIter(ctx context.Context, owner string, repo string, ref string, opts *ListOptions) iter.Seq2[*RepoStatus, error] { return func(yield func(*RepoStatus, error) bool) { diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index b8412d9dfa6..a85629d5be8 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -1023,6 +1023,78 @@ func TestActivityService_ListWatchersIter(t *testing.T) { } } +func TestAppsService_ListHookDeliveriesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Apps.ListHookDeliveriesIter(t.Context(), nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Apps.ListHookDeliveriesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListCursorOptions{} + iter = client.Apps.ListHookDeliveriesIter(t.Context(), opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Apps.ListHookDeliveriesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Apps.ListHookDeliveriesIter(t.Context(), nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Apps.ListHookDeliveriesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Apps.ListHookDeliveriesIter(t.Context(), nil) + gotItems = 0 + iter(func(item *HookDelivery, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Apps.ListHookDeliveriesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestAppsService_ListInstallationRequestsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -2247,6 +2319,150 @@ func TestEnterpriseService_ListAssignmentsIter(t *testing.T) { } } +func TestEnterpriseService_ListCodeSecurityConfigurationRepositoriesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListCodeSecurityConfigurationRepositoriesOptions{} + iter = client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) + gotItems = 0 + iter(func(item *RepositoryAttachment, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationRepositoriesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestEnterpriseService_ListCodeSecurityConfigurationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Enterprise.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListEnterpriseCodeSecurityConfigurationOptions{} + iter = client.Enterprise.ListCodeSecurityConfigurationsIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationsIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Enterprise.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationsIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Enterprise.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *CodeSecurityConfiguration, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Enterprise.ListCodeSecurityConfigurationsIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestEnterpriseService_ListOrganizationCustomPropertyValuesIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -4407,7 +4623,7 @@ func TestOrganizationsService_ListBlockedUsersIter(t *testing.T) { } } -func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { +func TestOrganizationsService_ListCodeSecurityConfigurationRepositoriesIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4415,7 +4631,7 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -4428,7 +4644,7 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { } }) - iter := client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) + iter := client.Organizations.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -4437,11 +4653,11 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationRepositoriesIter call 1 got %v items; want %v", gotItems, want) } - opts := &CredentialAuthorizationsListOptions{} - iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", opts) + opts := &ListCodeSecurityConfigurationRepositoriesOptions{} + iter = client.Organizations.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4450,10 +4666,10 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationRepositoriesIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) + iter = client.Organizations.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4462,12 +4678,12 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationRepositoriesIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) + iter = client.Organizations.ListCodeSecurityConfigurationRepositoriesIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *CredentialAuthorization, err error) bool { + iter(func(item *RepositoryAttachment, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4475,11 +4691,11 @@ func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationRepositoriesIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { +func TestOrganizationsService_ListCodeSecurityConfigurationsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4487,7 +4703,7 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -4500,7 +4716,7 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { } }) - iter := client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) + iter := client.Organizations.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -4509,11 +4725,11 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListCustomPropertyValuesOptions{} - iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", opts) + opts := &ListOrgCodeSecurityConfigurationOptions{} + iter = client.Organizations.ListCodeSecurityConfigurationsIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4522,10 +4738,10 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) + iter = client.Organizations.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4534,12 +4750,12 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) + iter = client.Organizations.ListCodeSecurityConfigurationsIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *RepoCustomPropertyValue, err error) bool { + iter(func(item *CodeSecurityConfiguration, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4547,11 +4763,11 @@ func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCodeSecurityConfigurationsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { +func TestOrganizationsService_ListCredentialAuthorizationsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4572,7 +4788,7 @@ func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { } }) - iter := client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + iter := client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -4581,11 +4797,11 @@ func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOptions{} - iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", opts) + opts := &CredentialAuthorizationsListOptions{} + iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4594,10 +4810,10 @@ func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4606,12 +4822,12 @@ func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + iter = client.Organizations.ListCredentialAuthorizationsIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *Invitation, err error) bool { + iter(func(item *CredentialAuthorization, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4619,11 +4835,11 @@ func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCredentialAuthorizationsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing.T) { +func TestOrganizationsService_ListCustomPropertyValuesIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4644,7 +4860,7 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing } }) - iter := client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + iter := client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -4653,11 +4869,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListFineGrainedPATOptions{} - iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", opts) + opts := &ListCustomPropertyValuesOptions{} + iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4666,10 +4882,10 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4678,12 +4894,12 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing } } if gotItems != 1 { - t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + iter = client.Organizations.ListCustomPropertyValuesIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *PersonalAccessToken, err error) bool { + iter(func(item *RepoCustomPropertyValue, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4691,11 +4907,11 @@ func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListCustomPropertyValuesIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListHooksIter(t *testing.T) { +func TestOrganizationsService_ListFailedOrgInvitationsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4716,7 +4932,223 @@ func TestOrganizationsService_ListHooksIter(t *testing.T) { } }) - iter := client.Organizations.ListHooksIter(t.Context(), "", nil) + iter := client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListOptions{} + iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListFailedOrgInvitationsIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *Invitation, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListFailedOrgInvitationsIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListFineGrainedPersonalAccessTokensIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListFineGrainedPATOptions{} + iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListFineGrainedPersonalAccessTokensIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *PersonalAccessToken, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListFineGrainedPersonalAccessTokensIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListHookDeliveriesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListHookDeliveriesIter(t.Context(), "", 0, nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListHookDeliveriesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListCursorOptions{} + iter = client.Organizations.ListHookDeliveriesIter(t.Context(), "", 0, opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListHookDeliveriesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListHookDeliveriesIter(t.Context(), "", 0, nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListHookDeliveriesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListHookDeliveriesIter(t.Context(), "", 0, nil) + gotItems = 0 + iter(func(item *HookDelivery, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListHookDeliveriesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListHooksIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListHooksIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -4729,7 +5161,439 @@ func TestOrganizationsService_ListHooksIter(t *testing.T) { } opts := &ListOptions{} - iter = client.Organizations.ListHooksIter(t.Context(), "", opts) + iter = client.Organizations.ListHooksIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListHooksIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListHooksIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListHooksIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListHooksIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *Hook, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListHooksIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListMembersIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListMembersIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListMembersIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListMembersOptions{} + iter = client.Organizations.ListMembersIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListMembersIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListMembersIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListMembersIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListMembersIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *User, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListMembersIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListOptions{} + iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + gotItems = 0 + iter(func(item *Team, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListOrgMembershipsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListOrgMembershipsOptions{} + iter = client.Organizations.ListOrgMembershipsIter(t.Context(), opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListOrgMembershipsIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListOrgMembershipsIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + gotItems = 0 + iter(func(item *Membership, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListOrgMembershipsIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListOutsideCollaboratorsOptions{} + iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *User, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListPackagesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListPackagesIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListPackagesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &PackageListOptions{} + iter = client.Organizations.ListPackagesIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Organizations.ListPackagesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Organizations.ListPackagesIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Organizations.ListPackagesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Organizations.ListPackagesIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *Package, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Organizations.ListPackagesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + +func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListOptions{} + iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4738,10 +5602,10 @@ func TestOrganizationsService_ListHooksIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListHooksIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListHooksIter(t.Context(), "", nil) + iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4750,12 +5614,12 @@ func TestOrganizationsService_ListHooksIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListHooksIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListHooksIter(t.Context(), "", nil) + iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *Hook, err error) bool { + iter(func(item *Invitation, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4763,11 +5627,11 @@ func TestOrganizationsService_ListHooksIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListHooksIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListMembersIter(t *testing.T) { +func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4788,7 +5652,7 @@ func TestOrganizationsService_ListMembersIter(t *testing.T) { } }) - iter := client.Organizations.ListMembersIter(t.Context(), "", nil) + iter := client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -4797,11 +5661,11 @@ func TestOrganizationsService_ListMembersIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListMembersIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListMembersOptions{} - iter = client.Organizations.ListMembersIter(t.Context(), "", opts) + opts := &ListOptions{} + iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4810,10 +5674,10 @@ func TestOrganizationsService_ListMembersIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListMembersIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListMembersIter(t.Context(), "", nil) + iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4822,12 +5686,12 @@ func TestOrganizationsService_ListMembersIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListMembersIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListMembersIter(t.Context(), "", nil) + iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *User, err error) bool { + iter(func(item *Team, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4835,11 +5699,11 @@ func TestOrganizationsService_ListMembersIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListMembersIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { +func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4860,7 +5724,7 @@ func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { } }) - iter := client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + iter := client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -4869,11 +5733,11 @@ func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 1 got %v items; want %v", gotItems, want) } opts := &ListOptions{} - iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", opts) + iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4882,10 +5746,10 @@ func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4894,12 +5758,12 @@ func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListOrgInvitationTeamsIter(t.Context(), "", "", nil) + iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *Team, err error) bool { + iter(func(item *User, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4907,11 +5771,11 @@ func TestOrganizationsService_ListOrgInvitationTeamsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListOrgInvitationTeamsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { +func TestProjectsService_ListOrganizationProjectFieldsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4919,7 +5783,7 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -4932,7 +5796,7 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { } }) - iter := client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + iter := client.Projects.ListOrganizationProjectFieldsIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -4941,11 +5805,11 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListOrgMembershipsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectFieldsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOrgMembershipsOptions{} - iter = client.Organizations.ListOrgMembershipsIter(t.Context(), opts) + opts := &ListProjectsOptions{} + iter = client.Projects.ListOrganizationProjectFieldsIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -4954,10 +5818,10 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListOrgMembershipsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectFieldsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + iter = client.Projects.ListOrganizationProjectFieldsIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -4966,12 +5830,12 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListOrgMembershipsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectFieldsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListOrgMembershipsIter(t.Context(), nil) + iter = client.Projects.ListOrganizationProjectFieldsIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *Membership, err error) bool { + iter(func(item *ProjectV2Field, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -4979,11 +5843,11 @@ func TestOrganizationsService_ListOrgMembershipsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListOrgMembershipsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectFieldsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { +func TestProjectsService_ListOrganizationProjectItemsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -4991,7 +5855,7 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -5004,7 +5868,7 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { } }) - iter := client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + iter := client.Projects.ListOrganizationProjectItemsIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -5013,11 +5877,11 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectItemsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOutsideCollaboratorsOptions{} - iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", opts) + opts := &ListProjectItemsOptions{} + iter = client.Projects.ListOrganizationProjectItemsIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -5026,10 +5890,10 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectItemsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + iter = client.Projects.ListOrganizationProjectItemsIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -5038,12 +5902,12 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectItemsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListOutsideCollaboratorsIter(t.Context(), "", nil) + iter = client.Projects.ListOrganizationProjectItemsIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *User, err error) bool { + iter(func(item *ProjectV2Item, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -5051,11 +5915,11 @@ func TestOrganizationsService_ListOutsideCollaboratorsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListOutsideCollaboratorsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectItemsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListPackagesIter(t *testing.T) { +func TestProjectsService_ListOrganizationProjectsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -5063,7 +5927,7 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -5076,7 +5940,7 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { } }) - iter := client.Organizations.ListPackagesIter(t.Context(), "", nil) + iter := client.Projects.ListOrganizationProjectsIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -5085,11 +5949,11 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListPackagesIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectsIter call 1 got %v items; want %v", gotItems, want) } - opts := &PackageListOptions{} - iter = client.Organizations.ListPackagesIter(t.Context(), "", opts) + opts := &ListProjectsOptions{} + iter = client.Projects.ListOrganizationProjectsIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -5098,10 +5962,10 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListPackagesIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListOrganizationProjectsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListPackagesIter(t.Context(), "", nil) + iter = client.Projects.ListOrganizationProjectsIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -5110,12 +5974,12 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListPackagesIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListPackagesIter(t.Context(), "", nil) + iter = client.Projects.ListOrganizationProjectsIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *Package, err error) bool { + iter(func(item *ProjectV2, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -5123,11 +5987,11 @@ func TestOrganizationsService_ListPackagesIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListPackagesIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListOrganizationProjectsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { +func TestProjectsService_ListUserProjectFieldsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -5135,7 +5999,7 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -5148,7 +6012,7 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { } }) - iter := client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) + iter := client.Projects.ListUserProjectFieldsIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -5157,11 +6021,11 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectFieldsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOptions{} - iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", opts) + opts := &ListProjectsOptions{} + iter = client.Projects.ListUserProjectFieldsIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -5170,10 +6034,10 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectFieldsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) + iter = client.Projects.ListUserProjectFieldsIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -5182,12 +6046,12 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectFieldsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListPendingOrgInvitationsIter(t.Context(), "", nil) + iter = client.Projects.ListUserProjectFieldsIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *Invitation, err error) bool { + iter(func(item *ProjectV2Field, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -5195,11 +6059,11 @@ func TestOrganizationsService_ListPendingOrgInvitationsIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListPendingOrgInvitationsIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectFieldsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { +func TestProjectsService_ListUserProjectItemsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -5207,7 +6071,7 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -5220,7 +6084,7 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { } }) - iter := client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter := client.Projects.ListUserProjectItemsIter(t.Context(), "", 0, nil) var gotItems int for _, err := range iter { gotItems++ @@ -5229,11 +6093,11 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectItemsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOptions{} - iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, opts) + opts := &ListProjectItemsOptions{} + iter = client.Projects.ListUserProjectItemsIter(t.Context(), "", 0, opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -5242,10 +6106,10 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectItemsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter = client.Projects.ListUserProjectItemsIter(t.Context(), "", 0, nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -5254,12 +6118,12 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectItemsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListTeamsAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter = client.Projects.ListUserProjectItemsIter(t.Context(), "", 0, nil) gotItems = 0 - iter(func(item *Team, err error) bool { + iter(func(item *ProjectV2Item, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -5267,11 +6131,11 @@ func TestOrganizationsService_ListTeamsAssignedToOrgRoleIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListTeamsAssignedToOrgRoleIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectItemsIter call 4 got %v items; want 1 (an error)", gotItems) } } -func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { +func TestProjectsService_ListUserProjectsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) var callNum int @@ -5279,7 +6143,7 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { callNum++ switch callNum { case 1: - w.Header().Set("Link", `; rel="next"`) + w.Header().Set("Link", `; rel="next"`) fmt.Fprint(w, `[{},{},{}]`) case 2: fmt.Fprint(w, `[{},{},{},{}]`) @@ -5292,7 +6156,7 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { } }) - iter := client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter := client.Projects.ListUserProjectsIter(t.Context(), "", nil) var gotItems int for _, err := range iter { gotItems++ @@ -5301,11 +6165,11 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { } } if want := 7; gotItems != want { - t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 1 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectsIter call 1 got %v items; want %v", gotItems, want) } - opts := &ListOptions{} - iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, opts) + opts := &ListProjectsOptions{} + iter = client.Projects.ListUserProjectsIter(t.Context(), "", opts) gotItems = 0 for _, err := range iter { gotItems++ @@ -5314,10 +6178,10 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { } } if want := 2; gotItems != want { - t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 2 got %v items; want %v", gotItems, want) + t.Errorf("client.Projects.ListUserProjectsIter call 2 got %v items; want %v", gotItems, want) } - iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter = client.Projects.ListUserProjectsIter(t.Context(), "", nil) gotItems = 0 for _, err := range iter { gotItems++ @@ -5326,12 +6190,12 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { } } if gotItems != 1 { - t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 3 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectsIter call 3 got %v items; want 1 (an error)", gotItems) } - iter = client.Organizations.ListUsersAssignedToOrgRoleIter(t.Context(), "", 0, nil) + iter = client.Projects.ListUserProjectsIter(t.Context(), "", nil) gotItems = 0 - iter(func(item *User, err error) bool { + iter(func(item *ProjectV2, err error) bool { gotItems++ if err != nil { t.Errorf("Unexpected error: %v", err) @@ -5339,7 +6203,7 @@ func TestOrganizationsService_ListUsersAssignedToOrgRoleIter(t *testing.T) { return false }) if gotItems != 1 { - t.Errorf("client.Organizations.ListUsersAssignedToOrgRoleIter call 4 got %v items; want 1 (an error)", gotItems) + t.Errorf("client.Projects.ListUserProjectsIter call 4 got %v items; want 1 (an error)", gotItems) } } @@ -7431,6 +8295,78 @@ func TestRepositoriesService_ListForksIter(t *testing.T) { } } +func TestRepositoriesService_ListHookDeliveriesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Repositories.ListHookDeliveriesIter(t.Context(), "", "", 0, nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Repositories.ListHookDeliveriesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListCursorOptions{} + iter = client.Repositories.ListHookDeliveriesIter(t.Context(), "", "", 0, opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Repositories.ListHookDeliveriesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Repositories.ListHookDeliveriesIter(t.Context(), "", "", 0, nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Repositories.ListHookDeliveriesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Repositories.ListHookDeliveriesIter(t.Context(), "", "", 0, nil) + gotItems = 0 + iter(func(item *HookDelivery, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Repositories.ListHookDeliveriesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestRepositoriesService_ListHooksIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -7935,6 +8871,78 @@ func TestRepositoriesService_ListReleasesIter(t *testing.T) { } } +func TestRepositoriesService_ListRepositoryActivitiesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `[{},{},{}]`) + case 2: + fmt.Fprint(w, `[{},{},{},{}]`) + case 3: + fmt.Fprint(w, `[{},{}]`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `[{},{}]`) + } + }) + + iter := client.Repositories.ListRepositoryActivitiesIter(t.Context(), "", "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Repositories.ListRepositoryActivitiesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListRepositoryActivityOptions{} + iter = client.Repositories.ListRepositoryActivitiesIter(t.Context(), "", "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Repositories.ListRepositoryActivitiesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Repositories.ListRepositoryActivitiesIter(t.Context(), "", "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Repositories.ListRepositoryActivitiesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Repositories.ListRepositoryActivitiesIter(t.Context(), "", "", nil) + gotItems = 0 + iter(func(item *RepositoryActivity, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Repositories.ListRepositoryActivitiesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestRepositoriesService_ListStatusesIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t)