MCPcopy
hub / github.com/github/github-mcp-server / Test_GetPullRequestComments

Function Test_GetPullRequestComments

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

Source from the content-addressed store, hash-verified

1873}
1874
1875func Test_GetPullRequestComments(t *testing.T) {
1876 // Verify tool definition once
1877 serverTool := PullRequestRead(translations.NullTranslationHelper)
1878 tool := serverTool.Tool
1879 require.NoError(t, toolsnaps.Test(tool.Name, tool))
1880
1881 assert.Equal(t, "pull_request_read", tool.Name)
1882 assert.NotEmpty(t, tool.Description)
1883 schema := tool.InputSchema.(*jsonschema.Schema)
1884 assert.Contains(t, schema.Properties, "method")
1885 assert.Contains(t, schema.Properties, "owner")
1886 assert.Contains(t, schema.Properties, "repo")
1887 assert.Contains(t, schema.Properties, "pullNumber")
1888 // `after` is required for cursor-based pagination on get_review_comments
1889 // to be reachable from MCP clients; without it in the schema, callers
1890 // cannot advance past the first page (issue #2122).
1891 assert.Contains(t, schema.Properties, "after")
1892 assert.Equal(t, "string", schema.Properties["after"].Type)
1893 assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"})
1894
1895 tests := []struct {
1896 name string
1897 gqlHTTPClient *http.Client
1898 requestArgs map[string]any
1899 expectError bool
1900 expectedErrMsg string
1901 lockdownEnabled bool
1902 validateResult func(t *testing.T, textContent string)
1903 }{
1904 {
1905 name: "successful review threads fetch",
1906 gqlHTTPClient: githubv4mock.NewMockedHTTPClient(
1907 githubv4mock.NewQueryMatcher(
1908 reviewThreadsQuery{},
1909 map[string]any{
1910 "owner": githubv4.String("owner"),
1911 "repo": githubv4.String("repo"),
1912 "prNum": githubv4.Int(42),
1913 "first": githubv4.Int(30),
1914 "commentsPerThread": githubv4.Int(100),
1915 "after": (*githubv4.String)(nil),
1916 },
1917 githubv4mock.DataResponse(map[string]any{
1918 "repository": map[string]any{
1919 "pullRequest": map[string]any{
1920 "reviewThreads": map[string]any{
1921 "nodes": []map[string]any{
1922 {
1923 "id": "RT_kwDOA0xdyM4AX1Yz",
1924 "isResolved": false,
1925 "isOutdated": false,
1926 "isCollapsed": false,
1927 "comments": map[string]any{
1928 "totalCount": 2,
1929 "nodes": []map[string]any{
1930 {
1931 "id": "PRRC_kwDOA0xdyM4AX1Y0",
1932 "body": "This looks good",

Callers

nothing calls this directly

Calls 15

TestFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
DataResponseFunction · 0.92
ErrorResponseFunction · 0.92
PullRequestReadFunction · 0.85
mockRESTPermissionServerFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85

Tested by

no test coverage detected