stems fixes and tests

This commit is contained in:
2026-03-13 01:17:27 -04:00
parent 797a0a5460
commit 6a275e1d90
9 changed files with 304 additions and 115 deletions

175
fixtures/stems.json Normal file
View File

@ -0,0 +1,175 @@
[
{
"description": "Stem Engine Unit Tests",
"database": {
"puncs": [],
"enums": [],
"relations": [
{
"id": "rel1",
"type": "relation",
"constraint": "fk_contact_entity",
"source_type": "contact",
"source_columns": ["entity_id"],
"destination_type": "person",
"destination_columns": ["id"],
"prefix": null
},
{
"id": "rel2",
"type": "relation",
"constraint": "fk_relationship_target",
"source_type": "relationship",
"source_columns": ["target_id", "target_type"],
"destination_type": "entity",
"destination_columns": ["id", "type"],
"prefix": "target"
}
],
"types": [
{
"name": "entity",
"hierarchy": ["entity"],
"schemas": [{
"$id": "entity",
"type": "object",
"properties": {}
}]
},
{
"name": "person",
"hierarchy": ["person", "entity"],
"schemas": [{
"$id": "person",
"$ref": "entity",
"properties": {}
}]
},
{
"name": "email_address",
"hierarchy": ["email_address", "entity"],
"schemas": [{
"$id": "email_address",
"$ref": "entity",
"properties": {}
}]
},
{
"name": "phone_number",
"hierarchy": ["phone_number", "entity"],
"schemas": [{
"$id": "phone_number",
"$ref": "entity",
"properties": {}
}]
},
{
"name": "relationship",
"relationship": true,
"hierarchy": ["relationship", "entity"],
"schemas": [{
"$id": "relationship",
"$ref": "entity",
"properties": {}
}]
},
{
"name": "contact",
"relationship": true,
"hierarchy": ["contact", "relationship", "entity"],
"schemas": [{
"$id": "contact",
"$ref": "relationship",
"properties": {
"target": {
"oneOf": [
{ "$ref": "phone_number" },
{ "$ref": "email_address" }
]
}
}
}]
},
{
"name": "save_person",
"schemas": [{
"$id": "save_person.response",
"$ref": "person",
"properties": {
"contacts": {
"type": "array",
"items": { "$ref": "contact" }
}
}
}]
}
]
},
"tests": [
{
"description": "correctly squashes deep oneOf refs through array paths",
"action": "compile",
"expect": {
"success": true,
"stems": {
"save_person.response": {
"": {
"type": "person"
},
"contacts/contact": {
"type": "contact",
"relation": "contacts_id"
},
"contacts/contact/email_address": {
"type": "email_address",
"relation": "target_id"
},
"contacts/contact/phone_number": {
"type": "phone_number",
"relation": "target_id"
}
},
"contact": {
"": {
"type": "contact"
},
"email_address": {
"type": "email_address",
"relation": "target_id"
},
"phone_number": {
"type": "phone_number",
"relation": "target_id"
}
},
"person": {
"": {
"type": "person"
}
},
"email_address": {
"": {
"type": "email_address"
}
},
"phone_number": {
"": {
"type": "phone_number"
}
},
"relationship": {
"": {
"type": "relationship"
}
},
"entity": {
"": {
"type": "entity"
}
}
}
}
}
]
}
]