Browse Source

Add missing ListOptions to various structs

Make it possible for callers of IssuesService.ListMilestones() and
similar to step through pages of results.
Bryan Boreham 10 years ago
committed by Glenn Lewis
parent
commit
c2beba44cf
6 changed files with 12 additions and 3 deletions
  1. +2
    -0
      github/activity_notifications.go
  2. +2
    -0
      github/issues_milestones.go
  3. +2
    -1
      github/issues_milestones_test.go
  4. +2
    -0
      github/orgs.go
  5. +2
    -0
      github/users.go
  6. +2
    -2
      github/users_test.go

+ 2
- 0
github/activity_notifications.go View File

@ -42,6 +42,8 @@ type NotificationListOptions struct {
Participating bool `url:"participating,omitempty"`
Since time.Time `url:"since,omitempty"`
Before time.Time `url:"before,omitempty"`
ListOptions
}
// ListNotifications lists all notifications for the authenticated user.


+ 2
- 0
github/issues_milestones.go View File

@ -47,6 +47,8 @@ type MilestoneListOptions struct {
// Direction in which to sort milestones. Possible values are: asc, desc.
// Default is "asc".
Direction string `url:"direction,omitempty"`
ListOptions
}
// ListMilestones lists all milestones for a repository.


+ 2
- 1
github/issues_milestones_test.go View File

@ -23,11 +23,12 @@ func TestIssuesService_ListMilestones(t *testing.T) {
"state": "closed",
"sort": "due_date",
"direction": "asc",
"page": "2",
})
fmt.Fprint(w, `[{"number":1}]`)
})
opt := &MilestoneListOptions{"closed", "due_date", "asc"}
opt := &MilestoneListOptions{"closed", "due_date", "asc", ListOptions{Page: 2}}
milestones, _, err := client.Issues.ListMilestones("o", "r", opt)
if err != nil {
t.Errorf("IssuesService.ListMilestones returned error: %v", err)


+ 2
- 0
github/orgs.go View File

@ -73,6 +73,8 @@ func (p Plan) String() string {
type OrganizationsListOptions struct {
// Since filters Organizations by ID.
Since int `url:"since,omitempty"`
ListOptions
}
// ListAll lists all organizations, in the order that they were created on GitHub.


+ 2
- 0
github/users.go View File

@ -138,6 +138,8 @@ func (s *UsersService) Edit(user *User) (*User, *Response, error) {
type UserListOptions struct {
// ID of the last user seen
Since int `url:"since,omitempty"`
ListOptions
}
// ListAll lists all GitHub users.


+ 2
- 2
github/users_test.go View File

@ -155,11 +155,11 @@ func TestUsersService_ListAll(t *testing.T) {
mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"since": "1"})
testFormValues(t, r, values{"since": "1", "page": "2"})
fmt.Fprint(w, `[{"id":2}]`)
})
opt := &UserListOptions{1}
opt := &UserListOptions{1, ListOptions{Page: 2}}
users, _, err := client.Users.ListAll(opt)
if err != nil {
t.Errorf("Users.Get returned error: %v", err)


Loading…
Cancel
Save