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

Function runDiscussionCommentWriteTests

pkg/github/discussions_test.go:1650–1690  ·  view source on GitHub ↗
(t *testing.T, tests []discussionCommentWriteTestCase)

Source from the content-addressed store, hash-verified

1648}
1649
1650func runDiscussionCommentWriteTests(t *testing.T, tests []discussionCommentWriteTestCase) {
1651 t.Helper()
1652
1653 toolDef := DiscussionCommentWrite(translations.NullTranslationHelper)
1654 for _, tc := range tests {
1655 t.Run(tc.name, func(t *testing.T) {
1656 gqlClient := githubv4.NewClient(tc.mockedClient)
1657 deps := BaseDeps{GQLClient: gqlClient}
1658 handler := toolDef.Handler(deps)
1659
1660 req := createMCPRequest(tc.requestArgs)
1661 res, err := handler(ContextWithDeps(context.Background(), deps), &req)
1662 require.NoError(t, err)
1663
1664 text := getTextResult(t, res).Text
1665
1666 if tc.expectToolError {
1667 require.True(t, res.IsError)
1668 assert.Contains(t, text, tc.expectedErrMsg)
1669 return
1670 }
1671
1672 require.False(t, res.IsError)
1673
1674 if tc.expectedDiscussionID != "" {
1675 var response struct {
1676 DiscussionID string `json:"discussionID"`
1677 DiscussionURL string `json:"discussionURL"`
1678 }
1679 require.NoError(t, json.Unmarshal([]byte(text), &response))
1680 assert.Equal(t, tc.expectedDiscussionID, response.DiscussionID)
1681 assert.Equal(t, tc.expectedDiscussionURL, response.DiscussionURL)
1682 } else {
1683 var response MinimalResponse
1684 require.NoError(t, json.Unmarshal([]byte(text), &response))
1685 assert.Equal(t, tc.expectedID, response.ID)
1686 assert.Equal(t, tc.expectedURL, response.URL)
1687 }
1688 })
1689 }
1690}
1691
1692func discussionCommentWriteDiscussionQueryMatcher(discussionNumber int32, response githubv4mock.GQLResponse) githubv4mock.Matcher {
1693 return githubv4mock.NewQueryMatcher(

Calls 5

DiscussionCommentWriteFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected