(t *testing.T)
| 547 | } |
| 548 | |
| 549 | func TestHandleExtractMetadata_AggregateFunctions(t *testing.T) { |
| 550 | ctx := context.Background() |
| 551 | req := makeReq(map[string]any{ |
| 552 | "sql": "SELECT COUNT(*), SUM(amount), AVG(price), MIN(id), MAX(id) FROM orders", |
| 553 | }) |
| 554 | res, err := handleExtractMetadata(ctx, req) |
| 555 | if err != nil { |
| 556 | t.Fatalf("unexpected error: %v", err) |
| 557 | } |
| 558 | data := unmarshalResult(t, res) |
| 559 | functions, ok := data["functions"].([]any) |
| 560 | if !ok { |
| 561 | t.Fatalf("expected functions to be []any, got %T", data["functions"]) |
| 562 | } |
| 563 | fnSet := make(map[string]bool) |
| 564 | for _, fn := range functions { |
| 565 | s, ok := fn.(string) |
| 566 | if !ok { |
| 567 | t.Fatalf("expected function name to be string, got %T", fn) |
| 568 | } |
| 569 | fnSet[s] = true |
| 570 | } |
| 571 | for _, expected := range []string{"COUNT", "SUM", "AVG", "MIN", "MAX"} { |
| 572 | if !fnSet[expected] { |
| 573 | t.Errorf("expected function %q in functions, got %v", expected, functions) |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | func TestHandleSecurityScan_TautologyAttack(t *testing.T) { |
| 579 | ctx := context.Background() |
nothing calls this directly
no test coverage detected