Skip to content

Add ListCursorOptions to list Issues methods #3570

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

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
8 changes: 8 additions & 0 deletions github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ type IssueListOptions struct {
// Since filters issues by time.
Since time.Time `url:"since,omitempty"`

ListCursorOptions

// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
// since ListCursorOptions accepts "page" as string only.
ListOptions
}

Expand Down Expand Up @@ -234,6 +238,10 @@ type IssueListByRepoOptions struct {
// Since filters issues by time.
Since time.Time `url:"since,omitempty"`

ListCursorOptions

// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
// since ListCursorOptions accepts "page" as string only.
ListOptions
}

Expand Down
9 changes: 7 additions & 2 deletions github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ func TestIssuesService_List_all(t *testing.T) {
"since": "2002-02-10T15:30:00Z",
"page": "1",
"per_page": "2",
"before": "foo",
"after": "bar",
})
fmt.Fprint(w, `[{"number":1}]`)
})

opt := &IssueListOptions{
"all", "closed", []string{"a", "b"}, "updated", "asc",
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
ListOptions{Page: 1, PerPage: 2},
ListCursorOptions{Before: "foo", After: "bar"}, ListOptions{Page: 1, PerPage: 2},
}
ctx := context.Background()
issues, _, err := client.Issues.List(ctx, true, opt)
Expand Down Expand Up @@ -155,14 +157,17 @@ func TestIssuesService_ListByRepo(t *testing.T) {
"sort": "updated",
"direction": "asc",
"since": "2002-02-10T15:30:00Z",
"per_page": "1",
"before": "foo",
"after": "bar",
})
fmt.Fprint(w, `[{"number":1}]`)
})

opt := &IssueListByRepoOptions{
"*", "closed", "a", "c", "m", []string{"a", "b"}, "updated", "asc",
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
ListOptions{0, 0},
ListCursorOptions{PerPage: 1, Before: "foo", After: "bar"}, ListOptions{0, 0},
}
ctx := context.Background()
issues, _, err := client.Issues.ListByRepo(ctx, "o", "r", opt)
Expand Down
Loading