Browse Source

add pagination support to Activity.ListWatchers

this is a breaking change, but there's no way around that, since the opt
param was left off initially.
Will Norris 12 years ago
parent
commit
3561cc2930
2 changed files with 10 additions and 2 deletions
  1. +5
    -1
      github/activity_watching.go
  2. +5
    -1
      github/activity_watching_test.go

+ 5
- 1
github/activity_watching.go View File

@ -15,8 +15,12 @@ type RepositorySubscription struct {
// ListWatchers lists watchers of a particular repo.
//
// GitHub API Docs: http://developer.github.com/v3/activity/watching/#list-watchers
func (s *ActivityService) ListWatchers(owner, repo string) ([]User, *Response, error) {
func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]User, *Response, error) {
u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo)
u, err := addOptions(u, opt)
if err != nil {
return nil, nil, err
}
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {


+ 5
- 1
github/activity_watching_test.go View File

@ -14,10 +14,14 @@ func TestActivityService_ListWatchers(t *testing.T) {
mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"page": "2",
})
fmt.Fprint(w, `[{"id":1}]`)
})
watchers, _, err := client.Activity.ListWatchers("o", "r")
watchers, _, err := client.Activity.ListWatchers("o", "r", &ListOptions{Page: 2})
if err != nil {
t.Errorf("Activity.ListWatchers returned error: %v", err)
}


Loading…
Cancel
Save