(t *testing.T)
| 3521 | } |
| 3522 | |
| 3523 | func Test_GetIssueParent(t *testing.T) { |
| 3524 | t.Parallel() |
| 3525 | |
| 3526 | serverTool := IssueRead(translations.NullTranslationHelper) |
| 3527 | |
| 3528 | parentMatcherStruct := struct { |
| 3529 | Repository struct { |
| 3530 | Issue struct { |
| 3531 | Parent *struct { |
| 3532 | Number githubv4.Int |
| 3533 | Title githubv4.String |
| 3534 | State githubv4.String |
| 3535 | URL githubv4.String |
| 3536 | Repository struct { |
| 3537 | NameWithOwner githubv4.String |
| 3538 | } |
| 3539 | } |
| 3540 | } `graphql:"issue(number: $issueNumber)"` |
| 3541 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 3542 | }{} |
| 3543 | |
| 3544 | vars := map[string]any{ |
| 3545 | "owner": githubv4.String("owner"), |
| 3546 | "repo": githubv4.String("repo"), |
| 3547 | "issueNumber": githubv4.Int(123), |
| 3548 | } |
| 3549 | |
| 3550 | tests := []struct { |
| 3551 | name string |
| 3552 | mockedClient *http.Client |
| 3553 | expectToolError bool |
| 3554 | expectedText string |
| 3555 | }{ |
| 3556 | { |
| 3557 | name: "issue has a parent", |
| 3558 | mockedClient: githubv4mock.NewMockedHTTPClient( |
| 3559 | githubv4mock.NewQueryMatcher( |
| 3560 | parentMatcherStruct, |
| 3561 | vars, |
| 3562 | githubv4mock.DataResponse(map[string]any{ |
| 3563 | "repository": map[string]any{ |
| 3564 | "issue": map[string]any{ |
| 3565 | "parent": map[string]any{ |
| 3566 | "number": githubv4.Int(42), |
| 3567 | "title": githubv4.String("Parent issue"), |
| 3568 | "state": githubv4.String("OPEN"), |
| 3569 | "url": githubv4.String("https://github.com/owner/repo/issues/42"), |
| 3570 | "repository": map[string]any{ |
| 3571 | "nameWithOwner": githubv4.String("owner/repo"), |
| 3572 | }, |
| 3573 | }, |
| 3574 | }, |
| 3575 | }, |
| 3576 | }), |
| 3577 | ), |
| 3578 | ), |
| 3579 | expectedText: `"number":42`, |
| 3580 | }, |
nothing calls this directly
no test coverage detected