Browse Source

Add pagination for listing comments

Add ListOptions to PullRequestListCommentsOptions and
IssueListCommentsOptions
Mat Geist 11 years ago
parent
commit
64bf2296e6
4 changed files with 16 additions and 4 deletions
  1. +2
    -0
      github/issues_comments.go
  2. +6
    -2
      github/issues_comments_test.go
  3. +2
    -0
      github/pulls_comments.go
  4. +6
    -2
      github/pulls_comments_test.go

+ 2
- 0
github/issues_comments.go View File

@ -37,6 +37,8 @@ type IssueListCommentsOptions struct {
// Since filters comments by time. // Since filters comments by time.
Since time.Time `url:"since,omitempty"` Since time.Time `url:"since,omitempty"`
ListOptions
} }
// ListComments lists all comments on the specified issue. Specifying an issue // ListComments lists all comments on the specified issue. Specifying an issue


+ 6
- 2
github/issues_comments_test.go View File

@ -24,12 +24,16 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) {
"sort": "updated", "sort": "updated",
"direction": "desc", "direction": "desc",
"since": "2002-02-10T15:30:00Z", "since": "2002-02-10T15:30:00Z",
"page": "2",
}) })
fmt.Fprint(w, `[{"id":1}]`) fmt.Fprint(w, `[{"id":1}]`)
}) })
opt := &IssueListCommentsOptions{"updated", "desc",
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
opt := &IssueListCommentsOptions{
Sort: "updated",
Direction: "desc",
Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
ListOptions: ListOptions{Page: 2},
} }
comments, _, err := client.Issues.ListComments("o", "r", 0, opt) comments, _, err := client.Issues.ListComments("o", "r", 0, opt)
if err != nil { if err != nil {


+ 2
- 0
github/pulls_comments.go View File

@ -37,6 +37,8 @@ type PullRequestListCommentsOptions struct {
// Since filters comments by time. // Since filters comments by time.
Since time.Time `url:"since,omitempty"` Since time.Time `url:"since,omitempty"`
ListOptions
} }
// ListComments lists all comments on the specified pull request. Specifying a // ListComments lists all comments on the specified pull request. Specifying a


+ 6
- 2
github/pulls_comments_test.go View File

@ -24,12 +24,16 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) {
"sort": "updated", "sort": "updated",
"direction": "desc", "direction": "desc",
"since": "2002-02-10T15:30:00Z", "since": "2002-02-10T15:30:00Z",
"page": "2",
}) })
fmt.Fprint(w, `[{"id":1}]`) fmt.Fprint(w, `[{"id":1}]`)
}) })
opt := &PullRequestListCommentsOptions{"updated", "desc",
time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
opt := &PullRequestListCommentsOptions{
Sort: "updated",
Direction: "desc",
Since: time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC),
ListOptions: ListOptions{Page: 2},
} }
pulls, _, err := client.PullRequests.ListComments("o", "r", 0, opt) pulls, _, err := client.PullRequests.ListComments("o", "r", 0, opt)


Loading…
Cancel
Save