(t *testing.T)
| 454 | } |
| 455 | |
| 456 | func TestPullRequestsService_Edit(t *testing.T) { |
| 457 | t.Parallel() |
| 458 | client, mux, _ := setup(t) |
| 459 | |
| 460 | tests := []struct { |
| 461 | input *PullRequest |
| 462 | sendResponse string |
| 463 | want *PullRequest |
| 464 | wantUpdate *pullRequestUpdate |
| 465 | }{ |
| 466 | { |
| 467 | input: &PullRequest{Title: Ptr("t")}, |
| 468 | sendResponse: `{"number":1}`, |
| 469 | want: &PullRequest{Number: Ptr(1)}, |
| 470 | wantUpdate: &pullRequestUpdate{ |
| 471 | Title: Ptr("t"), |
| 472 | }, |
| 473 | }, |
| 474 | { |
| 475 | // base update |
| 476 | input: &PullRequest{Base: &PullRequestBranch{Ref: Ptr("master")}}, |
| 477 | sendResponse: `{"number":1,"base":{"ref":"master"}}`, |
| 478 | want: &PullRequest{ |
| 479 | Number: Ptr(1), |
| 480 | Base: &PullRequestBranch{Ref: Ptr("master")}, |
| 481 | }, |
| 482 | wantUpdate: &pullRequestUpdate{ |
| 483 | Base: Ptr("master"), |
| 484 | }, |
| 485 | }, |
| 486 | } |
| 487 | |
| 488 | for i, tt := range tests { |
| 489 | madeRequest := false |
| 490 | mux.HandleFunc(fmt.Sprintf("/repos/o/r/pulls/%v", i), func(w http.ResponseWriter, r *http.Request) { |
| 491 | testMethod(t, r, "PATCH") |
| 492 | testJSONBody(t, r, tt.wantUpdate) |
| 493 | _, err := io.WriteString(w, tt.sendResponse) |
| 494 | assertNilError(t, err) |
| 495 | madeRequest = true |
| 496 | }) |
| 497 | |
| 498 | ctx := t.Context() |
| 499 | pull, _, err := client.PullRequests.Edit(ctx, "o", "r", i, tt.input) |
| 500 | if err != nil { |
| 501 | t.Errorf("%v: PullRequests.Edit returned error: %v", i, err) |
| 502 | } |
| 503 | |
| 504 | if !cmp.Equal(pull, tt.want) { |
| 505 | t.Errorf("%v: PullRequests.Edit returned %+v, want %+v", i, pull, tt.want) |
| 506 | } |
| 507 | |
| 508 | if !madeRequest { |
| 509 | t.Errorf("%v: PullRequest.Edit did not make the expected request", i) |
| 510 | } |
| 511 | |
| 512 | const methodName = "Edit" |
| 513 | testBadOptions(t, methodName, func() (err error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…