(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestActivityService_ListStargazers(t *testing.T) { |
| 19 | t.Parallel() |
| 20 | client, mux, _ := setup(t) |
| 21 | |
| 22 | mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) { |
| 23 | testMethod(t, r, "GET") |
| 24 | testHeader(t, r, "Accept", mediaTypeStarring) |
| 25 | testFormValues(t, r, values{ |
| 26 | "page": "2", |
| 27 | }) |
| 28 | |
| 29 | fmt.Fprint(w, `[{"starred_at":"2002-02-10T15:30:00Z","user":{"id":1}}]`) |
| 30 | }) |
| 31 | |
| 32 | ctx := t.Context() |
| 33 | stargazers, _, err := client.Activity.ListStargazers(ctx, "o", "r", &ListOptions{Page: 2}) |
| 34 | if err != nil { |
| 35 | t.Errorf("Activity.ListStargazers returned error: %v", err) |
| 36 | } |
| 37 | |
| 38 | want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Ptr(int64(1))}}} |
| 39 | if !cmp.Equal(stargazers, want) { |
| 40 | t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want) |
| 41 | } |
| 42 | |
| 43 | const methodName = "ListStargazers" |
| 44 | testBadOptions(t, methodName, func() (err error) { |
| 45 | _, _, err = client.Activity.ListStargazers(ctx, "\n", "\n", &ListOptions{Page: 2}) |
| 46 | return err |
| 47 | }) |
| 48 | |
| 49 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 50 | got, resp, err := client.Activity.ListStargazers(ctx, "o", "r", &ListOptions{Page: 2}) |
| 51 | if got != nil { |
| 52 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 53 | } |
| 54 | return resp, err |
| 55 | }) |
| 56 | } |
| 57 | |
| 58 | func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { |
| 59 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…