MCPcopy
hub / github.com/grafana/tempo / TestHandleSearch

Function TestHandleSearch

modules/frontend/mcp_tools_test.go:45–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestHandleSearch(t *testing.T) {
46 server, callAndTestResults := testFrontend()
47
48 tests := []struct {
49 name string
50 request mcp.CallToolRequest
51 expected expectedResult
52 }{
53 {
54 name: "query only",
55 request: callToolRequest(map[string]any{
56 "query": "{ span.foo = \"bar\" }",
57 }),
58 expected: expectedResult{
59 path: "/api/search",
60 params: map[string]string{
61 "q": "{ span.foo = \"bar\" }",
62 },
63 meta: map[string]any{
64 "type": "search-results",
65 "encoding": "json",
66 "version": "1",
67 },
68 },
69 },
70 {
71 name: "no query!",
72 request: callToolRequest(map[string]any{}),
73 expected: expectedResult{
74 err: "required argument \"query\" not found",
75 },
76 },
77 {
78 name: "query + start + end",
79 request: callToolRequest(map[string]any{
80 "query": "{ span.foo = \"bar\" }",
81 "start": "2022-01-01T00:00:00Z",
82 "end": "2022-01-02T00:00:00Z",
83 }),
84 expected: expectedResult{
85 path: "/api/search",
86 params: map[string]string{
87 "q": "{ span.foo = \"bar\" }",
88 "start": "1640995200",
89 "end": "1641081600",
90 },
91 meta: map[string]any{
92 "type": "search-results",
93 "encoding": "json",
94 "version": "1",
95 },
96 },
97 },
98 {
99 name: "bad query",
100 request: callToolRequest(map[string]any{
101 "query": "{ foo bar baz }",
102 }),

Callers

nothing calls this directly

Calls 3

testFrontendFunction · 0.85
callToolRequestFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected