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

Function Test_GetNotificationDetails

pkg/github/notifications_test.go:662–739  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

660}
661
662func Test_GetNotificationDetails(t *testing.T) {
663 // Verify tool definition and schema
664 serverTool := GetNotificationDetails(translations.NullTranslationHelper)
665 tool := serverTool.Tool
666 require.NoError(t, toolsnaps.Test(tool.Name, tool))
667
668 assert.Equal(t, "get_notification_details", tool.Name)
669 assert.NotEmpty(t, tool.Description)
670
671 schema, ok := tool.InputSchema.(*jsonschema.Schema)
672 require.True(t, ok, "InputSchema should be *jsonschema.Schema")
673 assert.Contains(t, schema.Properties, "notificationID")
674 assert.Equal(t, []string{"notificationID"}, schema.Required)
675
676 mockThread := &github.Notification{ID: github.Ptr("123"), Reason: github.Ptr("mention")}
677
678 tests := []struct {
679 name string
680 mockedClient *http.Client
681 requestArgs map[string]any
682 expectError bool
683 expectResult *github.Notification
684 expectedErrMsg string
685 }{
686 {
687 name: "success",
688 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
689 GetNotificationsThreadsByThreadID: mockResponse(t, http.StatusOK, mockThread),
690 }),
691 requestArgs: map[string]any{
692 "notificationID": "123",
693 },
694 expectError: false,
695 expectResult: mockThread,
696 },
697 {
698 name: "not found",
699 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
700 GetNotificationsThreadsByThreadID: mockResponse(t, http.StatusNotFound, `{"message": "not found"}`),
701 }),
702 requestArgs: map[string]any{
703 "notificationID": "123",
704 },
705 expectError: true,
706 expectedErrMsg: "not found",
707 },
708 }
709
710 for _, tc := range tests {
711 t.Run(tc.name, func(t *testing.T) {
712 client := mustNewGHClient(t, tc.mockedClient)
713 deps := BaseDeps{
714 Client: client,
715 }
716 handler := serverTool.Handler(deps)
717 request := createMCPRequest(tc.requestArgs)
718 result, err := handler(ContextWithDeps(context.Background(), deps), &request)
719

Callers

nothing calls this directly

Calls 10

TestFunction · 0.92
GetNotificationDetailsFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
HandlerMethod · 0.45

Tested by

no test coverage detected