MCPcopy Create free account
hub / github.com/bytebase/bytebase / mockQueryServer

Function mockQueryServer

backend/api/mcp/tool_query_test.go:169–180  ·  view source on GitHub ↗

mockQueryServer returns an HTTP handler that routes to ListDatabases or Query based on the request URL path.

(databases []map[string]any, queryResp map[string]any)

Source from the content-addressed store, hash-verified

167// mockQueryServer returns an HTTP handler that routes to ListDatabases or Query
168// based on the request URL path.
169func mockQueryServer(databases []map[string]any, queryResp map[string]any) http.Handler {
170 listHandler := mockListDatabases(databases)
171 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
172 if strings.Contains(r.URL.Path, "SQLService/Query") {
173 w.Header().Set("Content-Type", "application/json")
174 w.WriteHeader(http.StatusOK)
175 _ = json.NewEncoder(w).Encode(queryResp)
176 return
177 }
178 listHandler.ServeHTTP(w, r)
179 })
180}
181
182func TestBuildDatabaseFilter(t *testing.T) {
183 tests := []struct {

Calls 2

mockListDatabasesFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected