(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func 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 | }), |
nothing calls this directly
no test coverage detected