(t *testing.T)
| 295 | } |
| 296 | |
| 297 | func TestIssuesService_Create(t *testing.T) { |
| 298 | t.Parallel() |
| 299 | client, mux, _ := setup(t) |
| 300 | |
| 301 | input := &IssueRequest{ |
| 302 | Title: Ptr("t"), |
| 303 | Body: Ptr("b"), |
| 304 | Assignee: Ptr("a"), |
| 305 | Labels: &[]string{"l1", "l2"}, |
| 306 | } |
| 307 | |
| 308 | mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) { |
| 309 | testMethod(t, r, "POST") |
| 310 | testJSONBody(t, r, input) |
| 311 | fmt.Fprint(w, `{"number":1}`) |
| 312 | }) |
| 313 | |
| 314 | ctx := t.Context() |
| 315 | issue, _, err := client.Issues.Create(ctx, "o", "r", input) |
| 316 | if err != nil { |
| 317 | t.Errorf("Issues.Create returned error: %v", err) |
| 318 | } |
| 319 | |
| 320 | want := &Issue{Number: Ptr(1)} |
| 321 | if !cmp.Equal(issue, want) { |
| 322 | t.Errorf("Issues.Create returned %+v, want %+v", issue, want) |
| 323 | } |
| 324 | |
| 325 | const methodName = "Create" |
| 326 | testBadOptions(t, methodName, func() (err error) { |
| 327 | _, _, err = client.Issues.Create(ctx, "\n", "\n", input) |
| 328 | return err |
| 329 | }) |
| 330 | |
| 331 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 332 | got, resp, err := client.Issues.Create(ctx, "o", "r", input) |
| 333 | if got != nil { |
| 334 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 335 | } |
| 336 | return resp, err |
| 337 | }) |
| 338 | } |
| 339 | |
| 340 | func TestIssuesService_Create_invalidOwner(t *testing.T) { |
| 341 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…