--------------------------------------------------------------------------- handleLintSQL ---------------------------------------------------------------------------
(t *testing.T)
| 317 | // --------------------------------------------------------------------------- |
| 318 | |
| 319 | func 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 |
nothing calls this directly
no test coverage detected