(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestIssueImportService_Create(t *testing.T) { |
| 19 | t.Parallel() |
| 20 | client, mux, _ := setup(t) |
| 21 | |
| 22 | createdAt := time.Date(2020, time.August, 11, 15, 30, 0, 0, time.UTC) |
| 23 | input := &IssueImportRequest{ |
| 24 | IssueImport: IssueImport{ |
| 25 | Assignee: Ptr("developer"), |
| 26 | Body: "Dummy description", |
| 27 | CreatedAt: &Timestamp{createdAt}, |
| 28 | Labels: []string{"l1", "l2"}, |
| 29 | Milestone: Ptr(1), |
| 30 | Title: "Dummy Issue", |
| 31 | }, |
| 32 | Comments: []*Comment{{ |
| 33 | CreatedAt: &Timestamp{createdAt}, |
| 34 | Body: "Comment body", |
| 35 | }}, |
| 36 | } |
| 37 | |
| 38 | mux.HandleFunc("/repos/o/r/import/issues", func(w http.ResponseWriter, r *http.Request) { |
| 39 | testMethod(t, r, "POST") |
| 40 | testHeader(t, r, "Accept", mediaTypeIssueImportAPI) |
| 41 | testJSONBody(t, r, input) |
| 42 | assertWrite(t, w, issueImportResponseJSON) |
| 43 | }) |
| 44 | |
| 45 | ctx := t.Context() |
| 46 | got, _, err := client.IssueImport.Create(ctx, "o", "r", input) |
| 47 | if err != nil { |
| 48 | t.Errorf("Create returned error: %v", err) |
| 49 | } |
| 50 | |
| 51 | want := wantIssueImportResponse |
| 52 | if !cmp.Equal(got, want) { |
| 53 | t.Errorf("Create = %+v, want %+v", got, want) |
| 54 | } |
| 55 | |
| 56 | const methodName = "Create" |
| 57 | testBadOptions(t, methodName, func() (err error) { |
| 58 | _, _, err = client.IssueImport.Create(ctx, "\n", "\n", input) |
| 59 | return err |
| 60 | }) |
| 61 | |
| 62 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 63 | got, resp, err := client.IssueImport.Create(ctx, "o", "r", input) |
| 64 | if got != nil { |
| 65 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 66 | } |
| 67 | return resp, err |
| 68 | }) |
| 69 | } |
| 70 | |
| 71 | func TestIssueImportService_Create_deferred(t *testing.T) { |
| 72 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…