diff --git a/github/activity_watching.go b/github/activity_watching.go index 150cf66..c002b3b 100644 --- a/github/activity_watching.go +++ b/github/activity_watching.go @@ -50,13 +50,18 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([] // the empty string will fetch watched repos for the authenticated user. // // GitHub API Docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched -func (s *ActivityService) ListWatched(user string) ([]Repository, *Response, error) { +func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]Repository, *Response, error) { var u string if user != "" { u = fmt.Sprintf("users/%v/subscriptions", user) } else { u = "user/subscriptions" } + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index 8046ee2..a8a4a46 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -43,10 +43,13 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testFormValues(t, r, values{ + "page": "2", + }) fmt.Fprint(w, `[{"id":1}]`) }) - watched, _, err := client.Activity.ListWatched("") + watched, _, err := client.Activity.ListWatched("", &ListOptions{Page: 2}) if err != nil { t.Errorf("Activity.ListWatched returned error: %v", err) } @@ -63,10 +66,14 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { mux.HandleFunc("/users/u/subscriptions", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") + testFormValues(t, r, values{ + "page": "2", + }) fmt.Fprint(w, `[{"id":1}]`) }) - watched, _, err := client.Activity.ListWatched("u") + watched, _, err := client.Activity.ListWatched("u", &ListOptions{Page: 2}) + if err != nil { t.Errorf("Activity.ListWatched returned error: %v", err) }