(t *testing.T)
| 387 | } |
| 388 | |
| 389 | func Test_UpdatePullRequest_Draft(t *testing.T) { |
| 390 | // Setup mock PR for success case |
| 391 | mockUpdatedPR := &github.PullRequest{ |
| 392 | Number: github.Ptr(42), |
| 393 | Title: github.Ptr("Test PR Title"), |
| 394 | State: github.Ptr("open"), |
| 395 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"), |
| 396 | Body: github.Ptr("Test PR body."), |
| 397 | MaintainerCanModify: github.Ptr(false), |
| 398 | Draft: github.Ptr(false), // Updated to ready for review |
| 399 | Base: &github.PullRequestBranch{ |
| 400 | Ref: github.Ptr("main"), |
| 401 | }, |
| 402 | } |
| 403 | |
| 404 | tests := []struct { |
| 405 | name string |
| 406 | mockedClient *http.Client |
| 407 | requestArgs map[string]any |
| 408 | expectError bool |
| 409 | expectedPR *github.PullRequest |
| 410 | expectedErrMsg string |
| 411 | }{ |
| 412 | { |
| 413 | name: "successful draft update to ready for review", |
| 414 | mockedClient: githubv4mock.NewMockedHTTPClient( |
| 415 | githubv4mock.NewQueryMatcher( |
| 416 | struct { |
| 417 | Repository struct { |
| 418 | PullRequest struct { |
| 419 | ID githubv4.ID |
| 420 | IsDraft githubv4.Boolean |
| 421 | } `graphql:"pullRequest(number: $prNum)"` |
| 422 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 423 | }{}, |
| 424 | map[string]any{ |
| 425 | "owner": githubv4.String("owner"), |
| 426 | "repo": githubv4.String("repo"), |
| 427 | "prNum": githubv4.Int(42), |
| 428 | }, |
| 429 | githubv4mock.DataResponse(map[string]any{ |
| 430 | "repository": map[string]any{ |
| 431 | "pullRequest": map[string]any{ |
| 432 | "id": "PR_kwDOA0xdyM50BPaO", |
| 433 | "isDraft": true, // Current state is draft |
| 434 | }, |
| 435 | }, |
| 436 | }), |
| 437 | ), |
| 438 | githubv4mock.NewMutationMatcher( |
| 439 | struct { |
| 440 | MarkPullRequestReadyForReview struct { |
| 441 | PullRequest struct { |
| 442 | ID githubv4.ID |
| 443 | IsDraft githubv4.Boolean |
| 444 | } |
| 445 | } `graphql:"markPullRequestReadyForReview(input: $input)"` |
| 446 | }{}, |
nothing calls this directly
no test coverage detected