chore: initial commit of ai site platform
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
platform/internal/schema/ddl_test.go
Normal file
38
platform/internal/schema/ddl_test.go
Normal 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])
|
||||
}
|
||||
Reference in New Issue
Block a user