(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { |
| 17 | t.Parallel() |
| 18 | client, mux, _ := setup(t) |
| 19 | |
| 20 | mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) { |
| 21 | testMethod(t, r, "GET") |
| 22 | testFormValues(t, r, values{"page": "2"}) |
| 23 | fmt.Fprint(w, `[{"id":1}]`) |
| 24 | }) |
| 25 | |
| 26 | opt := &ListOptions{Page: 2} |
| 27 | ctx := t.Context() |
| 28 | keys, _, err := client.Users.ListKeys(ctx, "", opt) |
| 29 | if err != nil { |
| 30 | t.Errorf("Users.ListKeys returned error: %v", err) |
| 31 | } |
| 32 | |
| 33 | want := []*Key{{ID: Ptr(int64(1))}} |
| 34 | if !cmp.Equal(keys, want) { |
| 35 | t.Errorf("Users.ListKeys returned %+v, want %+v", keys, want) |
| 36 | } |
| 37 | |
| 38 | const methodName = "ListKeys" |
| 39 | testBadOptions(t, methodName, func() (err error) { |
| 40 | _, _, err = client.Users.ListKeys(ctx, "\n", opt) |
| 41 | return err |
| 42 | }) |
| 43 | |
| 44 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 45 | got, resp, err := client.Users.ListKeys(ctx, "", opt) |
| 46 | if got != nil { |
| 47 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 48 | } |
| 49 | return resp, err |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | func TestUsersService_ListKeys_specifiedUser(t *testing.T) { |
| 54 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…