Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix application of pagination options on ListCopilotSeats endpoint #3090

Merged
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
6 changes: 5 additions & 1 deletion github/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 8 additions & 3 deletions github/copilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -473,7 +477,8 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) {
lastActivityAt2 := Timestamp{tmp}

ctx := context.Background()
got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", nil)
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)
}
Expand Down Expand Up @@ -585,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)
}
Expand Down
Loading