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

Function TestHandleInstantQuery

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

Source from the content-addressed store, hash-verified

123}
124
125func TestHandleInstantQuery(t *testing.T) {
126 server, callAndTestResults := testFrontend()
127
128 tests := []struct {
129 name string
130 request mcp.CallToolRequest
131 expected expectedResult
132 }{
133 {
134 name: "query only",
135 request: callToolRequest(map[string]any{
136 "query": "{} | rate()",
137 }),
138 expected: expectedResult{
139 path: "/api/metrics/query",
140 params: map[string]string{
141 "q": "{} | rate()",
142 },
143 meta: map[string]any{
144 "type": "metrics-instant",
145 "encoding": "json",
146 "version": "1",
147 },
148 },
149 },
150 {
151 name: "no query",
152 request: callToolRequest(map[string]any{}),
153 expected: expectedResult{
154 err: "required argument \"query\" not found",
155 },
156 },
157 {
158 name: "query + start + end",
159 request: callToolRequest(map[string]any{
160 "query": "{} | rate()",
161 "start": "2022-01-01T00:00:00Z",
162 "end": "2022-01-02T00:00:00Z",
163 }),
164 expected: expectedResult{
165 path: "/api/metrics/query",
166 params: map[string]string{
167 "q": "{} | rate()",
168 "start": "1640995200000000000",
169 "end": "1641081600000000000",
170 },
171 meta: map[string]any{
172 "type": "metrics-instant",
173 "encoding": "json",
174 "version": "1",
175 },
176 },
177 },
178 {
179 name: "bad query",
180 request: callToolRequest(map[string]any{
181 "query": "{ foo bar baz }",
182 }),

Callers

nothing calls this directly

Calls 3

testFrontendFunction · 0.85
callToolRequestFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected