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

Function Test_SearchPullRequests

pkg/github/pullrequests_test.go:820–1105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

818}
819
820func 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(

Callers

nothing calls this directly

Calls 14

TestFunction · 0.92
SearchPullRequestsFunction · 0.85
expectQueryParamsFunction · 0.85
mockResponseFunction · 0.85
mustNewGHClientFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithDepsFunction · 0.85
getErrorResultFunction · 0.85
getTextResultFunction · 0.85
andThenMethod · 0.80
WriteHeaderMethod · 0.80

Tested by

no test coverage detected