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

Function TestQueryDatabase_HandleValidation

backend/api/mcp/tool_query_test.go:402–417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

400}
401
402func TestQueryDatabase_HandleValidation(t *testing.T) {
403 s := newTestServerWithMock(t, http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
404 w.WriteHeader(http.StatusOK)
405 fmt.Fprint(w, `{"databases": []}`)
406 }))
407
408 // Missing database.
409 _, _, err := s.handleQueryDatabase(context.Background(), nil, QueryInput{Statement: "SELECT 1"})
410 require.Error(t, err)
411 require.Contains(t, err.Error(), "database is required")
412
413 // Missing statement.
414 _, _, err = s.handleQueryDatabase(context.Background(), nil, QueryInput{Database: "employee_db"})
415 require.Error(t, err)
416 require.Contains(t, err.Error(), "statement is required")
417}
418
419func TestQueryDatabase_LimitNormalization(t *testing.T) {
420 // Verify limit is capped at maxQueryLimit via the handler.

Callers

nothing calls this directly

Calls 3

newTestServerWithMockFunction · 0.85
handleQueryDatabaseMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected