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

Function TestGetPullRequestDiff

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

Source from the content-addressed store, hash-verified

3755}
3756
3757func TestGetPullRequestDiff(t *testing.T) {
3758 t.Parallel()
3759
3760 // Verify tool definition once
3761 serverTool := PullRequestRead(translations.NullTranslationHelper)
3762 tool := serverTool.Tool
3763 require.NoError(t, toolsnaps.Test(tool.Name, tool))
3764
3765 assert.Equal(t, "pull_request_read", tool.Name)
3766 assert.NotEmpty(t, tool.Description)
3767 schema := tool.InputSchema.(*jsonschema.Schema)
3768 assert.Contains(t, schema.Properties, "method")
3769 assert.Contains(t, schema.Properties, "owner")
3770 assert.Contains(t, schema.Properties, "repo")
3771 assert.Contains(t, schema.Properties, "pullNumber")
3772 assert.ElementsMatch(t, schema.Required, []string{"method", "owner", "repo", "pullNumber"})
3773
3774 stubbedDiff := `diff --git a/README.md b/README.md
3775index 5d6e7b2..8a4f5c3 100644
3776--- a/README.md
3777+++ b/README.md
3778@@ -1,4 +1,6 @@
3779 # Hello-World
3780
3781 Hello World project for GitHub
3782
3783+## New Section
3784+
3785+This is a new section added in the pull request.`
3786
3787 tests := []struct {
3788 name string
3789 requestArgs map[string]any
3790 mockedClient *http.Client
3791 expectToolError bool
3792 expectedToolErrMsg string
3793 }{
3794 {
3795 name: "successful diff retrieval",
3796 requestArgs: map[string]any{
3797 "method": "get_diff",
3798 "owner": "owner",
3799 "repo": "repo",
3800 "pullNumber": float64(42),
3801 },
3802 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
3803 GetReposPullsByOwnerByRepoByPullNumber: expectPath(t, "/repos/owner/repo/pulls/42").andThen(
3804 mockResponse(t, http.StatusOK, stubbedDiff),
3805 ),
3806 }),
3807 expectToolError: false,
3808 },
3809 }
3810
3811 for _, tc := range tests {
3812 t.Run(tc.name, func(t *testing.T) {
3813 t.Parallel()
3814

Callers

nothing calls this directly

Calls 13

TestFunction · 0.92
PullRequestReadFunction · 0.85
expectPathFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
stubRepoAccessCacheFunction · 0.85
stubFeatureFlagsFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
andThenMethod · 0.80

Tested by

no test coverage detected