package schema_test import ( "encoding/json" "os" "path/filepath" "runtime" "testing" "aijianzhan/platform/internal/blueprint" "aijianzhan/platform/internal/schema" ) func TestBuildDDLFromExample(t *testing.T) { _, file, _, _ := runtime.Caller(0) root := filepath.Clean(filepath.Join(filepath.Dir(file), "..", "..", "..")) example := filepath.Join(root, "blueprint", "examples", "inventory-ledger.blueprint.json") raw, err := os.ReadFile(example) if err != nil { t.Fatalf("read example: %v", err) } bp, err := blueprint.Parse(json.RawMessage(raw)) if err != nil { t.Fatal(err) } if err := bp.Validate("inventory_ledger"); err != nil { t.Fatal(err) } bp.AssignSchemaName(1) stmts, err := schema.BuildPostgresDDL(bp) if err != nil { t.Fatal(err) } if len(stmts) < 2 { t.Fatalf("expected schema+table ddl, got %d", len(stmts)) } t.Logf("ddl count=%d first=%s", len(stmts), stmts[0]) }