Skip to content

Commit

Permalink
Add ListOptions to ListSelectedReposForOrgSecret (#1883)
Browse files Browse the repository at this point in the history
Fixes: #1882.
  • Loading branch information
gmlewis authored Jun 7, 2021
1 parent 773936a commit edaee9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion github/actions_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,13 @@ type SelectedReposList struct {
// ListSelectedReposForOrgSecret lists all repositories that have access to a secret.
//
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-selected-repositories-for-an-organization-secret
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string) (*SelectedReposList, *Response, error) {
func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name)
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
Expand Down
7 changes: 4 additions & 3 deletions github/actions_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,9 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) {
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
ctx := context.Background()
repos, _, err := client.Actions.ListSelectedReposForOrgSecret(ctx, "o", "NAME")
repos, _, err := client.Actions.ListSelectedReposForOrgSecret(ctx, "o", "NAME", opts)
if err != nil {
t.Errorf("Actions.ListSelectedReposForOrgSecret returned error: %v", err)
}
Expand All @@ -484,12 +485,12 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) {

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

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

0 comments on commit edaee9a

Please sign in to comment.