MCPcopy Index your code
hub / github.com/github/github-mcp-server / Test_GetPullRequestCheckRuns

Function Test_GetPullRequestCheckRuns

pkg/github/pullrequests_test.go:1604–1757  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1602}
1603
1604func 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{

Callers

nothing calls this directly

Calls 14

TestFunction · 0.92
PullRequestReadFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
WriteHeaderMethod · 0.80

Tested by

no test coverage detected