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

Function Test_SearchCommits

pkg/github/search_test.go:858–1015  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

856}
857
858func Test_SearchCommits(t *testing.T) {
859 serverTool := SearchCommits(translations.NullTranslationHelper)
860 tool := serverTool.Tool
861 require.NoError(t, toolsnaps.Test(tool.Name, tool))
862
863 assert.Equal(t, "search_commits", tool.Name)
864 assert.NotEmpty(t, tool.Description)
865
866 schema, ok := tool.InputSchema.(*jsonschema.Schema)
867 require.True(t, ok, "InputSchema should be *jsonschema.Schema")
868 assert.Contains(t, schema.Properties, "query")
869 assert.Contains(t, schema.Properties, "sort")
870 assert.Contains(t, schema.Properties, "order")
871 assert.Contains(t, schema.Properties, "page")
872 assert.Contains(t, schema.Properties, "perPage")
873 assert.ElementsMatch(t, schema.Required, []string{"query"})
874
875 now := time.Now().Truncate(time.Second)
876 mockSearchResult := &github.CommitsSearchResult{
877 Total: github.Ptr(2),
878 IncompleteResults: github.Ptr(false),
879 Commits: []*github.CommitResult{
880 {
881 SHA: github.Ptr("abc123commit"),
882 HTMLURL: github.Ptr("https://github.com/owner/repo/commit/abc123commit"),
883 Commit: &github.Commit{
884 Message: github.Ptr("Initial commit"),
885 Author: &github.CommitAuthor{
886 Name: github.Ptr("Author Name"),
887 Email: github.Ptr("author@example.com"),
888 Date: &github.Timestamp{Time: now},
889 },
890 },
891 Author: &github.User{
892 Login: github.Ptr("author"),
893 ID: github.Ptr(int64(1)),
894 HTMLURL: github.Ptr("https://github.com/author"),
895 },
896 Repository: &github.Repository{
897 FullName: github.Ptr("owner/repo"),
898 HTMLURL: github.Ptr("https://github.com/owner/repo"),
899 Private: github.Ptr(false),
900 },
901 },
902 {
903 // Commit with no resolved GitHub user for author or committer
904 // (common when the commit email isn't linked to an account).
905 SHA: github.Ptr("def456commit"),
906 HTMLURL: github.Ptr("https://github.com/owner/repo/commit/def456commit"),
907 Commit: &github.Commit{
908 Message: github.Ptr("Unlinked author"),
909 },
910 Repository: &github.Repository{
911 FullName: github.Ptr("owner/repo"),
912 },
913 },
914 },
915 }

Callers

nothing calls this directly

Calls 14

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