chore: initial commit of ai site platform

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-07-31 10:19:22 +08:00
commit 6366859bb3
222 changed files with 47313 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
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])
}