From edaee9aa26ea0b2fedd961398433b8940b2afef1 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 7 Jun 2021 15:51:02 -0400 Subject: [PATCH] Add ListOptions to ListSelectedReposForOrgSecret (#1883) Fixes: #1882. --- github/actions_secrets.go | 7 ++++++- github/actions_secrets_test.go | 7 ++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/github/actions_secrets.go b/github/actions_secrets.go index 4763d3a12a1..379eab81cbb 100644 --- a/github/actions_secrets.go +++ b/github/actions_secrets.go @@ -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 diff --git a/github/actions_secrets_test.go b/github/actions_secrets_test.go index 4e7ca87f425..e38836abb2a 100644 --- a/github/actions_secrets_test.go +++ b/github/actions_secrets_test.go @@ -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) } @@ -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) }