From cb0e47a5cc7c2f2a864e93cae1d6fe2d49b9e099 Mon Sep 17 00:00:00 2001 From: Ryan Skidmore Date: Mon, 4 Mar 2024 17:48:54 +0000 Subject: [PATCH 1/2] github: fix application of pagination options to URL --- github/copilot.go | 6 +++++- github/copilot_test.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 51c938c9748..50e05253ce5 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -161,8 +161,12 @@ func (s *CopilotService) GetCopilotBilling(ctx context.Context, org string) (*Co //meta:operation GET /orgs/{org}/copilot/billing/seats func (s *CopilotService) ListCopilotSeats(ctx context.Context, org string, opts *ListOptions) (*ListCopilotSeatsResponse, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot/billing/seats", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } - req, err := s.client.NewRequest("GET", u, opts) + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } diff --git a/github/copilot_test.go b/github/copilot_test.go index c65fda0f217..84395f23a9e 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -336,6 +336,10 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { mux.HandleFunc("/orgs/o/copilot/billing/seats", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testFormValues(t, r, values{ + "per_page": "100", + "page": "1", + }) fmt.Fprint(w, `{ "total_seats": 4, "seats": [ @@ -473,7 +477,7 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { lastActivityAt2 := Timestamp{tmp} ctx := context.Background() - got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", nil) + got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", &ListOptions{Page: 1, PerPage: 100}) if err != nil { t.Errorf("Copilot.ListCopilotSeats returned error: %v", err) } From 1289d98ab708d5c0ea7da2174ca43f26d7cbecae Mon Sep 17 00:00:00 2001 From: Ryan Skidmore Date: Tue, 5 Mar 2024 11:49:15 +0000 Subject: [PATCH 2/2] github: improve test coverage --- github/copilot_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index 84395f23a9e..008630ab273 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -477,7 +477,8 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { lastActivityAt2 := Timestamp{tmp} ctx := context.Background() - got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", &ListOptions{Page: 1, PerPage: 100}) + opts := &ListOptions{Page: 1, PerPage: 100} + got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", opts) if err != nil { t.Errorf("Copilot.ListCopilotSeats returned error: %v", err) } @@ -589,12 +590,12 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { const methodName = "ListCopilotSeats" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Copilot.ListCopilotSeats(ctx, "\n", nil) + _, _, err = client.Copilot.ListCopilotSeats(ctx, "\n", opts) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Copilot.ListCopilotSeats(ctx, "", nil) + got, resp, err := client.Copilot.ListCopilotSeats(ctx, "o", opts) if got != nil { t.Errorf("Copilot.ListCopilotSeats returned %+v, want nil", got) }