MCPcopy Create free account
hub / github.com/google/go-github / TestActivityService_ListWatchers

Function TestActivityService_ListWatchers

github/activity_watching_test.go:16–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestActivityService_ListWatchers(t *testing.T) {
17 t.Parallel()
18 client, mux, _ := setup(t)
19
20 mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) {
21 testMethod(t, r, "GET")
22 testFormValues(t, r, values{
23 "page": "2",
24 })
25
26 fmt.Fprint(w, `[{"id":1}]`)
27 })
28
29 ctx := t.Context()
30 watchers, _, err := client.Activity.ListWatchers(ctx, "o", "r", &ListOptions{Page: 2})
31 if err != nil {
32 t.Errorf("Activity.ListWatchers returned error: %v", err)
33 }
34
35 want := []*User{{ID: Ptr(int64(1))}}
36 if !cmp.Equal(watchers, want) {
37 t.Errorf("Activity.ListWatchers returned %+v, want %+v", watchers, want)
38 }
39
40 const methodName = "ListWatchers"
41 testBadOptions(t, methodName, func() (err error) {
42 _, _, err = client.Activity.ListWatchers(ctx, "\n", "\n", &ListOptions{Page: 2})
43 return err
44 })
45
46 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
47 got, resp, err := client.Activity.ListWatchers(ctx, "o", "r", &ListOptions{Page: 2})
48 if got != nil {
49 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
50 }
51 return resp, err
52 })
53}
54
55func TestActivityService_ListWatched_authenticatedUser(t *testing.T) {
56 t.Parallel()

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testFormValuesFunction · 0.85
testBadOptionsFunction · 0.85
ListWatchersMethod · 0.80
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…