From 3561cc2930c5da648103682f847453c3fd213288 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Thu, 10 Apr 2014 15:25:36 -0700 Subject: [PATCH] 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. --- github/activity_watching.go | 6 +++++- github/activity_watching_test.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/github/activity_watching.go b/github/activity_watching.go index 3af168a..0144285 100644 --- a/github/activity_watching.go +++ b/github/activity_watching.go @@ -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 { diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index 46a2d96..bd55480 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -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) }