(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestPullRequestsService_List(t *testing.T) { |
| 20 | t.Parallel() |
| 21 | client, mux, _ := setup(t) |
| 22 | |
| 23 | mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { |
| 24 | testMethod(t, r, "GET") |
| 25 | testFormValues(t, r, values{ |
| 26 | "state": "closed", |
| 27 | "head": "h", |
| 28 | "base": "b", |
| 29 | "sort": "created", |
| 30 | "direction": "desc", |
| 31 | "page": "2", |
| 32 | }) |
| 33 | fmt.Fprint(w, `[{"number":1}]`) |
| 34 | }) |
| 35 | |
| 36 | opts := &PullRequestListOptions{"closed", "h", "b", "created", "desc", ListOptions{Page: 2}} |
| 37 | ctx := t.Context() |
| 38 | pulls, _, err := client.PullRequests.List(ctx, "o", "r", opts) |
| 39 | if err != nil { |
| 40 | t.Errorf("PullRequests.List returned error: %v", err) |
| 41 | } |
| 42 | |
| 43 | want := []*PullRequest{{Number: Ptr(1)}} |
| 44 | if !cmp.Equal(pulls, want) { |
| 45 | t.Errorf("PullRequests.List returned %+v, want %+v", pulls, want) |
| 46 | } |
| 47 | |
| 48 | const methodName = "List" |
| 49 | testBadOptions(t, methodName, func() (err error) { |
| 50 | _, _, err = client.PullRequests.List(ctx, "\n", "\n", opts) |
| 51 | return err |
| 52 | }) |
| 53 | |
| 54 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 55 | got, resp, err := client.PullRequests.List(ctx, "o", "r", opts) |
| 56 | if got != nil { |
| 57 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 58 | } |
| 59 | return resp, err |
| 60 | }) |
| 61 | } |
| 62 | |
| 63 | func TestPullRequestsService_ListPullRequestsWithCommit(t *testing.T) { |
| 64 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…