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

Function TestGranularUpdateIssueState

pkg/github/granular_tools_test.go:893–946  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

891}
892
893func TestGranularUpdateIssueState(t *testing.T) {
894 tests := []struct {
895 name string
896 requestArgs map[string]any
897 expectedReq map[string]any
898 }{
899 {
900 name: "close with reason",
901 requestArgs: map[string]any{
902 "owner": "owner",
903 "repo": "repo",
904 "issue_number": float64(1),
905 "state": "closed",
906 "state_reason": "completed",
907 },
908 expectedReq: map[string]any{
909 "state": "closed",
910 "state_reason": "completed",
911 },
912 },
913 {
914 name: "reopen without reason",
915 requestArgs: map[string]any{
916 "owner": "owner",
917 "repo": "repo",
918 "issue_number": float64(1),
919 "state": "open",
920 },
921 expectedReq: map[string]any{
922 "state": "open",
923 },
924 },
925 }
926
927 for _, tc := range tests {
928 t.Run(tc.name, func(t *testing.T) {
929 client := mustNewGHClient(t, MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
930 PatchReposIssuesByOwnerByRepoByIssueNumber: expectRequestBody(t, tc.expectedReq).
931 andThen(mockResponse(t, http.StatusOK, &gogithub.Issue{
932 Number: gogithub.Ptr(1),
933 State: gogithub.Ptr(tc.requestArgs["state"].(string)),
934 })),
935 }))
936 deps := BaseDeps{Client: client}
937 serverTool := GranularUpdateIssueState(translations.NullTranslationHelper)
938 handler := serverTool.Handler(deps)
939
940 request := createMCPRequest(tc.requestArgs)
941 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
942 require.NoError(t, err)
943 assert.False(t, result.IsError)
944 })
945 }
946}
947
948// --- Pull request granular tool handler tests ---
949

Callers

nothing calls this directly

Calls 9

mustNewGHClientFunction · 0.85
expectRequestBodyFunction · 0.85
mockResponseFunction · 0.85
GranularUpdateIssueStateFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
andThenMethod · 0.80
HandlerMethod · 0.45

Tested by

no test coverage detected