Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions github/github-iterators.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions github/github-iterators_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions github/orgs_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"fmt"
)

// GetAllRepositoryRulesets gets all the repository rulesets for the specified organization.
// ListAllRepositoryRulesets gets all the repository rulesets for the specified organization.
//
// GitHub API docs: https://docs.github.com/rest/orgs/rules?apiVersion=2022-11-28#get-all-organization-repository-rulesets
//
//meta:operation GET /orgs/{org}/rulesets
func (s *OrganizationsService) GetAllRepositoryRulesets(ctx context.Context, org string, opts *ListOptions) ([]*RepositoryRuleset, *Response, error) {
func (s *OrganizationsService) ListAllRepositoryRulesets(ctx context.Context, org string, opts *ListOptions) ([]*RepositoryRuleset, *Response, error) {
u := fmt.Sprintf("orgs/%v/rulesets", org)

u, err := addOptions(u, opts)
Expand Down
26 changes: 13 additions & 13 deletions github/orgs_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/google/go-cmp/cmp"
)

func TestOrganizationsService_GetAllRepositoryRulesets(t *testing.T) {
func TestOrganizationsService_ListAllRepositoryRulesets(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

Expand All @@ -38,9 +38,9 @@ func TestOrganizationsService_GetAllRepositoryRulesets(t *testing.T) {
})

ctx := t.Context()
rulesets, _, err := client.Organizations.GetAllRepositoryRulesets(ctx, "o", nil)
rulesets, _, err := client.Organizations.ListAllRepositoryRulesets(ctx, "o", nil)
if err != nil {
t.Errorf("Organizations.GetAllRepositoryRulesets returned error: %v", err)
t.Errorf("Organizations.ListAllRepositoryRulesets returned error: %v", err)
}

want := []*RepositoryRuleset{{
Expand All @@ -56,20 +56,20 @@ func TestOrganizationsService_GetAllRepositoryRulesets(t *testing.T) {
},
}}
if !cmp.Equal(rulesets, want) {
t.Errorf("Organizations.GetAllRepositoryRulesets returned %+v, want %+v", rulesets, want)
t.Errorf("Organizations.ListAllRepositoryRulesets returned %+v, want %+v", rulesets, want)
}

const methodName = "GetAllRepositoryRulesets"
const methodName = "ListAllRepositoryRulesets"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Organizations.GetAllRepositoryRulesets(ctx, "o", nil)
got, resp, err := client.Organizations.ListAllRepositoryRulesets(ctx, "o", nil)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestOrganizationsService_GetAllRepositoryRulesets_ListOptions(t *testing.T) {
func TestOrganizationsService_ListAllRepositoryRulesets_ListOptions(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

Expand All @@ -86,26 +86,26 @@ func TestOrganizationsService_GetAllRepositoryRulesets_ListOptions(t *testing.T)

opts := &ListOptions{Page: 2, PerPage: 35}
ctx := t.Context()
rulesets, _, err := client.Organizations.GetAllRepositoryRulesets(ctx, "o", opts)
rulesets, _, err := client.Organizations.ListAllRepositoryRulesets(ctx, "o", opts)
if err != nil {
t.Errorf("Organizations.GetAllRepositoryRulesets returned error: %v", err)
t.Errorf("Organizations.ListAllRepositoryRulesets returned error: %v", err)
}

want := []*RepositoryRuleset{{
ID: Ptr(int64(21)),
}}
if !cmp.Equal(rulesets, want) {
t.Errorf("Organizations.GetAllRepositoryRulesets returned %+v, want %+v", rulesets, want)
t.Errorf("Organizations.ListAllRepositoryRulesets returned %+v, want %+v", rulesets, want)
}

const methodName = "GetAllRepositoryRulesets"
const methodName = "ListAllRepositoryRulesets"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Organizations.GetAllRepositoryRulesets(ctx, "\n", opts)
_, _, err = client.Organizations.ListAllRepositoryRulesets(ctx, "\n", opts)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Organizations.GetAllRepositoryRulesets(ctx, "o", opts)
got, resp, err := client.Organizations.ListAllRepositoryRulesets(ctx, "o", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down
Loading