add bracket syntax replace tests
This commit is contained in:
@ -13,11 +13,12 @@ func TestParseEntityDefinitions(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "entity with enhanced fields and relationships",
|
||||
input: `entity User desc "User management"
|
||||
input: `entity User desc "User management" {
|
||||
id: uuid required unique
|
||||
email: string required validate email validate min_length "5"
|
||||
name: string default "Anonymous"
|
||||
profile_id: uuid relates to Profile as one via "user_id"`,
|
||||
profile_id: uuid relates to Profile as one via "user_id"
|
||||
}`,
|
||||
want: AST{
|
||||
Definitions: []Definition{
|
||||
{
|
||||
@ -61,6 +62,57 @@ func TestParseEntityDefinitions(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "simple entity with basic fields",
|
||||
input: `entity Product {
|
||||
id: uuid required unique
|
||||
name: string required
|
||||
price: decimal default "0.00"
|
||||
}`,
|
||||
want: AST{
|
||||
Definitions: []Definition{
|
||||
{
|
||||
Entity: &Entity{
|
||||
Name: "Product",
|
||||
Fields: []Field{
|
||||
{
|
||||
Name: "id",
|
||||
Type: "uuid",
|
||||
Required: true,
|
||||
Unique: true,
|
||||
},
|
||||
{
|
||||
Name: "name",
|
||||
Type: "string",
|
||||
Required: true,
|
||||
},
|
||||
{
|
||||
Name: "price",
|
||||
Type: "decimal",
|
||||
Default: stringPtr("0.00"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "entity without fields block",
|
||||
input: `entity SimpleEntity`,
|
||||
want: AST{
|
||||
Definitions: []Definition{
|
||||
{
|
||||
Entity: &Entity{
|
||||
Name: "SimpleEntity",
|
||||
Fields: []Field{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
Reference in New Issue
Block a user