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

Function Test_SearchIssues

pkg/github/issues_test.go:563–909  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

561}
562
563func Test_SearchIssues(t *testing.T) {
564 // Verify tool definition once
565 serverTool := SearchIssues(translations.NullTranslationHelper)
566 tool := serverTool.Tool
567 require.NoError(t, toolsnaps.Test(tool.Name, tool))
568
569 assert.Equal(t, "search_issues", tool.Name)
570 assert.NotEmpty(t, tool.Description)
571 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "query")
572 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
573 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
574 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "sort")
575 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "order")
576 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "perPage")
577 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "page")
578 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"query"})
579
580 // Setup mock search results
581 mockSearchResult := &github.IssuesSearchResult{
582 Total: github.Ptr(2),
583 IncompleteResults: github.Ptr(false),
584 Issues: []*github.Issue{
585 {
586 Number: github.Ptr(42),
587 Title: github.Ptr("Bug: Something is broken"),
588 Body: github.Ptr("This is a bug report"),
589 State: github.Ptr("open"),
590 HTMLURL: github.Ptr("https://github.com/owner/repo/issues/42"),
591 Comments: github.Ptr(5),
592 User: &github.User{
593 Login: github.Ptr("user1"),
594 },
595 },
596 {
597 Number: github.Ptr(43),
598 Title: github.Ptr("Feature: Add new functionality"),
599 Body: github.Ptr("This is a feature request"),
600 State: github.Ptr("open"),
601 HTMLURL: github.Ptr("https://github.com/owner/repo/issues/43"),
602 Comments: github.Ptr(3),
603 User: &github.User{
604 Login: github.Ptr("user2"),
605 },
606 },
607 },
608 }
609
610 tests := []struct {
611 name string
612 mockedClient *http.Client
613 requestArgs map[string]any
614 expectError bool
615 expectedResult *github.IssuesSearchResult
616 expectedErrMsg string
617 }{
618 {
619 name: "successful issues search with all parameters",
620 mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{

Callers

nothing calls this directly

Calls 14

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