(t *testing.T)
| 1602 | } |
| 1603 | |
| 1604 | func Test_GetPullRequestCheckRuns(t *testing.T) { |
| 1605 | // Verify tool definition once |
| 1606 | serverTool := PullRequestRead(translations.NullTranslationHelper) |
| 1607 | tool := serverTool.Tool |
| 1608 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 1609 | |
| 1610 | assert.Equal(t, "pull_request_read", tool.Name) |
| 1611 | assert.NotEmpty(t, tool.Description) |
| 1612 | schema := tool.InputSchema.(*jsonschema.Schema) |
| 1613 | assert.Contains(t, schema.Properties, "method") |
| 1614 | assert.Contains(t, schema.Properties, "owner") |
| 1615 | assert.Contains(t, schema.Properties, "repo") |
| 1616 | assert.Contains(t, schema.Properties, "pullNumber") |
| 1617 | assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"}) |
| 1618 | |
| 1619 | // Setup mock PR for successful PR fetch |
| 1620 | mockPR := &github.PullRequest{ |
| 1621 | Number: github.Ptr(42), |
| 1622 | Title: github.Ptr("Test PR"), |
| 1623 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/42"), |
| 1624 | Head: &github.PullRequestBranch{ |
| 1625 | SHA: github.Ptr("abcd1234"), |
| 1626 | Ref: github.Ptr("feature-branch"), |
| 1627 | }, |
| 1628 | } |
| 1629 | |
| 1630 | // Setup mock check runs for success case |
| 1631 | mockCheckRuns := &github.ListCheckRunsResults{ |
| 1632 | Total: github.Ptr(2), |
| 1633 | CheckRuns: []*github.CheckRun{ |
| 1634 | { |
| 1635 | ID: github.Ptr(int64(1)), |
| 1636 | Name: github.Ptr("build"), |
| 1637 | Status: github.Ptr("completed"), |
| 1638 | Conclusion: github.Ptr("success"), |
| 1639 | HTMLURL: github.Ptr("https://github.com/owner/repo/runs/1"), |
| 1640 | }, |
| 1641 | { |
| 1642 | ID: github.Ptr(int64(2)), |
| 1643 | Name: github.Ptr("test"), |
| 1644 | Status: github.Ptr("completed"), |
| 1645 | Conclusion: github.Ptr("success"), |
| 1646 | HTMLURL: github.Ptr("https://github.com/owner/repo/runs/2"), |
| 1647 | }, |
| 1648 | }, |
| 1649 | } |
| 1650 | |
| 1651 | tests := []struct { |
| 1652 | name string |
| 1653 | mockedClient *http.Client |
| 1654 | requestArgs map[string]any |
| 1655 | expectError bool |
| 1656 | expectedCheckRuns *github.ListCheckRunsResults |
| 1657 | expectedErrMsg string |
| 1658 | }{ |
| 1659 | { |
| 1660 | name: "successful check runs fetch", |
| 1661 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
nothing calls this directly
no test coverage detected