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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion github/copilot.go
Expand Up @@ -161,8 +161,12 @@
//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

Check warning on line 166 in github/copilot.go

View check run for this annotation

Codecov / codecov/patch

github/copilot.go#L166

Added line #L166 was not covered by tests
}

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
6 changes: 5 additions & 1 deletion github/copilot_test.go
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,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})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test, we will also want to add:

	opts := &ListOptions{Page: 1, PerPage: 100}
	got, _, err := client.Copilot.ListCopilotSeats(ctx, "o", opts)
...
	const methodName = "ListCopilotSeats"
	testBadOptions(t, methodName, func() (err error) {
		_, _, err = client.Copilot.ListCopilotSeats(ctx, "\n", opts)
		return err
	})

	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
		got, resp, err := client.Copilot.ListCopilotSeats(ctx, "o", opts)
		if got != nil {
			t.Errorf("Copilot.ListCopilotSeats returned %+v, want nil", got)
		}
		return resp, err
	})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added these in - ty for the heads up. I don't think I can trigger the codecov workflow so I'm not sure if this has increased the coverage by enough!

if err != nil {
t.Errorf("Copilot.ListCopilotSeats returned error: %v", err)
}
Expand Down