Skip to content

Commit 6a2c098

Browse files
Add ListCursorOptions to list Issues methods (#3570)
1 parent 9a4137d commit 6a2c098

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

github/issues.go

+8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ type IssueListOptions struct {
118118
// Since filters issues by time.
119119
Since time.Time `url:"since,omitempty"`
120120

121+
ListCursorOptions
122+
123+
// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
124+
// since ListCursorOptions accepts "page" as string only.
121125
ListOptions
122126
}
123127

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

241+
ListCursorOptions
242+
243+
// Add ListOptions so offset pagination with integer type "page" query parameter is accepted
244+
// since ListCursorOptions accepts "page" as string only.
237245
ListOptions
238246
}
239247

github/issues_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ func TestIssuesService_List_all(t *testing.T) {
3232
"since": "2002-02-10T15:30:00Z",
3333
"page": "1",
3434
"per_page": "2",
35+
"before": "foo",
36+
"after": "bar",
3537
})
3638
fmt.Fprint(w, `[{"number":1}]`)
3739
})
3840

3941
opt := &IssueListOptions{
4042
"all", "closed", []string{"a", "b"}, "updated", "asc",
4143
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
42-
ListOptions{Page: 1, PerPage: 2},
44+
ListCursorOptions{Before: "foo", After: "bar"}, ListOptions{Page: 1, PerPage: 2},
4345
}
4446
ctx := context.Background()
4547
issues, _, err := client.Issues.List(ctx, true, opt)
@@ -155,14 +157,17 @@ func TestIssuesService_ListByRepo(t *testing.T) {
155157
"sort": "updated",
156158
"direction": "asc",
157159
"since": "2002-02-10T15:30:00Z",
160+
"per_page": "1",
161+
"before": "foo",
162+
"after": "bar",
158163
})
159164
fmt.Fprint(w, `[{"number":1}]`)
160165
})
161166

162167
opt := &IssueListByRepoOptions{
163168
"*", "closed", "a", "c", "m", []string{"a", "b"}, "updated", "asc",
164169
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
165-
ListOptions{0, 0},
170+
ListCursorOptions{PerPage: 1, Before: "foo", After: "bar"}, ListOptions{0, 0},
166171
}
167172
ctx := context.Background()
168173
issues, _, err := client.Issues.ListByRepo(ctx, "o", "r", opt)

0 commit comments

Comments
 (0)