(t *testing.T)
| 454 | } |
| 455 | |
| 456 | func TestHandleParseSQL_CTE(t *testing.T) { |
| 457 | ctx := context.Background() |
| 458 | req := makeReq(map[string]any{"sql": "WITH cte AS (SELECT 1) SELECT * FROM cte"}) |
| 459 | res, err := handleParseSQL(ctx, req) |
| 460 | if err != nil { |
| 461 | t.Fatalf("unexpected error: %v", err) |
| 462 | } |
| 463 | data := unmarshalResult(t, res) |
| 464 | count, ok := data["statement_count"].(float64) |
| 465 | if !ok || count != 1 { |
| 466 | t.Errorf("expected statement_count=1, got %v", data["statement_count"]) |
| 467 | } |
| 468 | types, ok := data["statement_types"].([]any) |
| 469 | if !ok || len(types) == 0 { |
| 470 | t.Fatalf("expected non-empty statement_types, got %v", data["statement_types"]) |
| 471 | } |
| 472 | if types[0] != "*ast.SelectStatement" { |
| 473 | t.Errorf("expected *ast.SelectStatement, got %v", types[0]) |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | func TestHandleParseSQL_WindowFunction(t *testing.T) { |
| 478 | ctx := context.Background() |
nothing calls this directly
no test coverage detected