MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestHandleLintSQL

Function TestHandleLintSQL

pkg/mcp/tools_test.go:319–352  ·  view source on GitHub ↗

--------------------------------------------------------------------------- handleLintSQL ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

317// ---------------------------------------------------------------------------
318
319func TestHandleLintSQL(t *testing.T) {
320 ctx := context.Background()
321
322 t.Run("valid SQL returns lint result", func(t *testing.T) {
323 req := makeReq(map[string]any{"sql": "SELECT id FROM users"})
324 res, err := handleLintSQL(ctx, req)
325 if err != nil {
326 t.Fatalf("unexpected error: %v", err)
327 }
328 data := unmarshalResult(t, res)
329 if _, ok := data["violation_count"]; !ok {
330 t.Error("expected 'violation_count' key in result")
331 }
332 if _, ok := data["violations"]; !ok {
333 t.Error("expected 'violations' key in result")
334 }
335 })
336
337 t.Run("empty sql returns protocol error", func(t *testing.T) {
338 req := makeReq(map[string]any{"sql": ""})
339 _, err := handleLintSQL(ctx, req)
340 if err == nil {
341 t.Fatal("expected error for empty sql, got nil")
342 }
343 })
344
345 t.Run("missing sql param returns protocol error", func(t *testing.T) {
346 req := makeReq(map[string]any{})
347 _, err := handleLintSQL(ctx, req)
348 if err == nil {
349 t.Fatal("expected error for missing sql param, got nil")
350 }
351 })
352}
353
354// ---------------------------------------------------------------------------
355// handleAnalyzeSQL

Callers

nothing calls this directly

Calls 6

makeReqFunction · 0.85
handleLintSQLFunction · 0.85
unmarshalResultFunction · 0.85
RunMethod · 0.80
FatalfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected