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

Function Test_ListNotifications

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

Source from the content-addressed store, hash-verified

15)
16
17func Test_ListNotifications(t *testing.T) {
18 // Verify tool definition and schema
19 serverTool := ListNotifications(translations.NullTranslationHelper)
20 tool := serverTool.Tool
21 require.NoError(t, toolsnaps.Test(tool.Name, tool))
22
23 assert.Equal(t, "list_notifications", tool.Name)
24 assert.NotEmpty(t, tool.Description)
25
26 schema, ok := tool.InputSchema.(*jsonschema.Schema)
27 require.True(t, ok, "InputSchema should be *jsonschema.Schema")
28 assert.Contains(t, schema.Properties, "filter")
29 assert.Contains(t, schema.Properties, "since")
30 assert.Contains(t, schema.Properties, "before")
31 assert.Contains(t, schema.Properties, "owner")
32 assert.Contains(t, schema.Properties, "repo")
33 assert.Contains(t, schema.Properties, "page")
34 assert.Contains(t, schema.Properties, "perPage")
35 // All fields are optional, so Required should be empty
36 assert.Empty(t, schema.Required)
37 mockNotification := &github.Notification{
38 ID: github.Ptr("123"),
39 Reason: github.Ptr("mention"),
40 }
41
42 tests := []struct {
43 name string
44 mockedClient *http.Client
45 requestArgs map[string]any
46 expectError bool
47 expectedResult []*github.Notification
48 expectedErrMsg string
49 }{
50 {
51 name: "success default filter (no params)",
52 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
53 GetNotifications: mockResponse(t, http.StatusOK, []*github.Notification{mockNotification}),
54 }),
55 requestArgs: map[string]any{},
56 expectError: false,
57 expectedResult: []*github.Notification{mockNotification},
58 },
59 {
60 name: "success with filter=include_read_notifications",
61 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
62 GetNotifications: mockResponse(t, http.StatusOK, []*github.Notification{mockNotification}),
63 }),
64 requestArgs: map[string]any{
65 "filter": "include_read_notifications",
66 },
67 expectError: false,
68 expectedResult: []*github.Notification{mockNotification},
69 },
70 {
71 name: "success with filter=only_participating",
72 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
73 GetNotifications: mockResponse(t, http.StatusOK, []*github.Notification{mockNotification}),
74 }),

Callers

nothing calls this directly

Calls 10

TestFunction · 0.92
ListNotificationsFunction · 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