(t *testing.T)
| 660 | } |
| 661 | |
| 662 | func 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 |
nothing calls this directly
no test coverage detected