(t *testing.T)
| 514 | } |
| 515 | |
| 516 | func TestHandleExtractMetadata_ComplexJoin(t *testing.T) { |
| 517 | ctx := context.Background() |
| 518 | req := makeReq(map[string]any{ |
| 519 | "sql": "SELECT a.id, b.name, c.value FROM alpha a JOIN beta b ON a.id = b.alpha_id JOIN gamma c ON b.id = c.beta_id", |
| 520 | }) |
| 521 | res, err := handleExtractMetadata(ctx, req) |
| 522 | if err != nil { |
| 523 | t.Fatalf("unexpected error: %v", err) |
| 524 | } |
| 525 | data := unmarshalResult(t, res) |
| 526 | tables, ok := data["tables"].([]any) |
| 527 | if !ok { |
| 528 | t.Fatalf("expected tables to be []any, got %T", data["tables"]) |
| 529 | } |
| 530 | if len(tables) < 3 { |
| 531 | t.Errorf("expected at least 3 tables, got %d: %v", len(tables), tables) |
| 532 | } |
| 533 | // Check that all three table names are present. |
| 534 | tableSet := make(map[string]bool) |
| 535 | for _, tbl := range tables { |
| 536 | s, ok := tbl.(string) |
| 537 | if !ok { |
| 538 | t.Fatalf("expected table name to be string, got %T", tbl) |
| 539 | } |
| 540 | tableSet[s] = true |
| 541 | } |
| 542 | for _, expected := range []string{"alpha", "beta", "gamma"} { |
| 543 | if !tableSet[expected] { |
| 544 | t.Errorf("expected table %q in tables, got %v", expected, tables) |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | func TestHandleExtractMetadata_AggregateFunctions(t *testing.T) { |
| 550 | ctx := context.Background() |
nothing calls this directly
no test coverage detected