(t *testing.T)
| 818 | } |
| 819 | |
| 820 | func Test_SearchPullRequests(t *testing.T) { |
| 821 | serverTool := SearchPullRequests(translations.NullTranslationHelper) |
| 822 | tool := serverTool.Tool |
| 823 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 824 | |
| 825 | assert.Equal(t, "search_pull_requests", tool.Name) |
| 826 | assert.NotEmpty(t, tool.Description) |
| 827 | schema := tool.InputSchema.(*jsonschema.Schema) |
| 828 | assert.Contains(t, schema.Properties, "query") |
| 829 | assert.Contains(t, schema.Properties, "owner") |
| 830 | assert.Contains(t, schema.Properties, "repo") |
| 831 | assert.Contains(t, schema.Properties, "sort") |
| 832 | assert.Contains(t, schema.Properties, "order") |
| 833 | assert.Contains(t, schema.Properties, "perPage") |
| 834 | assert.Contains(t, schema.Properties, "page") |
| 835 | assert.ElementsMatch(t, schema.Required, []string{"query"}) |
| 836 | |
| 837 | mockSearchResult := &github.IssuesSearchResult{ |
| 838 | Total: github.Ptr(2), |
| 839 | IncompleteResults: github.Ptr(false), |
| 840 | Issues: []*github.Issue{ |
| 841 | { |
| 842 | Number: github.Ptr(42), |
| 843 | Title: github.Ptr("Test PR 1"), |
| 844 | Body: github.Ptr("Updated tests."), |
| 845 | State: github.Ptr("open"), |
| 846 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/1"), |
| 847 | Comments: github.Ptr(5), |
| 848 | User: &github.User{ |
| 849 | Login: github.Ptr("user1"), |
| 850 | }, |
| 851 | }, |
| 852 | { |
| 853 | Number: github.Ptr(43), |
| 854 | Title: github.Ptr("Test PR 2"), |
| 855 | Body: github.Ptr("Updated build scripts."), |
| 856 | State: github.Ptr("open"), |
| 857 | HTMLURL: github.Ptr("https://github.com/owner/repo/pull/2"), |
| 858 | Comments: github.Ptr(3), |
| 859 | User: &github.User{ |
| 860 | Login: github.Ptr("user2"), |
| 861 | }, |
| 862 | }, |
| 863 | }, |
| 864 | } |
| 865 | |
| 866 | tests := []struct { |
| 867 | name string |
| 868 | mockedClient *http.Client |
| 869 | requestArgs map[string]any |
| 870 | expectError bool |
| 871 | expectedResult *github.IssuesSearchResult |
| 872 | expectedErrMsg string |
| 873 | }{ |
| 874 | { |
| 875 | name: "successful pull request search with all parameters", |
| 876 | mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
| 877 | GetSearchIssues: expectQueryParams( |
nothing calls this directly
no test coverage detected