test checkpoint

This commit is contained in:
2026-03-11 17:46:08 -04:00
parent 2c74d0a1a6
commit c007d7d479
3 changed files with 179 additions and 755 deletions

View File

@ -1,597 +1,11 @@
[
{
"description": "Basic Merger Execution",
"database": {
"puncs": [],
"enums": [],
"relations": [],
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"archived": {
"type": "boolean"
},
"created_by": {
"type": "string"
},
"modified_by": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"modified_at": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id",
"type",
"created_by",
"created_at",
"modified_by",
"modified_at"
]
}
],
"hierarchy": [
"entity"
],
"fields": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [],
"historical": false,
"relationship": false
},
{
"name": "simple_entity",
"schemas": [
{
"$id": "simple_entity",
"$ref": "entity",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
]
}
],
"hierarchy": [
"simple_entity",
"entity"
],
"fields": [
"id",
"type",
"name",
"created_at",
"created_by",
"modified_at",
"modified_by"
],
"grouped_fields": {
"simple_entity": [
"id",
"type",
"name"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by"
]
},
"lookup_fields": [],
"historical": false,
"relationship": false
}
]
},
"tests": [
{
"description": "Should execute a standard UPSERT via the mock database",
"action": "merge",
"data": {
"id": "123",
"type": "simple_entity",
"name": "Jane"
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) FROM agreego.\"simple_entity\" t1 LEFT JOIN agreego.\"entity\" t2 ON t2.id = t1.id WHERE t1.id = '123'",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '123', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'simple_entity')",
"INSERT INTO agreego.\"simple_entity\" (\"id\", \"name\", \"type\") VALUES ('123', 'Jane', 'simple_entity')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"name\":\"Jane\",\"type\":\"simple_entity\"}', '123', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"id\":\"123\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"name\":\"Jane\",\"type\":\"simple_entity\"}}')"
]
}
}
]
},
{
"description": "Hierarchical Lookups and Inserts",
"database": {
"puncs": [],
"enums": [],
"relations": [],
"types": [
{
"name": "entity",
"schemas": [
{
"$id": "entity",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"archived": {
"type": "boolean"
},
"created_by": {
"type": "string"
},
"modified_by": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"modified_at": {
"type": "string",
"format": "date-time"
}
},
"required": [
"id",
"type",
"created_by",
"created_at",
"modified_by",
"modified_at"
]
}
],
"hierarchy": [
"entity"
],
"fields": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [],
"historical": false,
"relationship": false
},
{
"name": "organization",
"schemas": [
{
"$id": "organization",
"$ref": "entity",
"properties": {
"name": {
"type": "string"
}
}
}
],
"hierarchy": [
"organization",
"entity"
],
"fields": [
"id",
"type",
"name",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"organization": [
"id",
"type",
"name"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [],
"historical": true,
"relationship": false
},
{
"name": "user",
"schemas": [
{
"$id": "user",
"$ref": "organization",
"properties": {}
}
],
"hierarchy": [
"user",
"organization",
"entity"
],
"fields": [
"id",
"type",
"name",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"user": [
"id",
"type"
],
"organization": [
"id",
"type",
"name"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [],
"historical": true,
"relationship": false
},
{
"name": "person",
"schemas": [
{
"$id": "person",
"$ref": "user",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"date_of_birth": {
"type": "string"
},
"pronouns": {
"type": "string"
},
"contact_id": {
"type": "string"
}
}
}
],
"hierarchy": [
"person",
"user",
"organization",
"entity"
],
"fields": [
"id",
"type",
"first_name",
"last_name",
"date_of_birth",
"pronouns",
"contact_id",
"name",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"person": [
"id",
"type",
"first_name",
"last_name",
"date_of_birth",
"pronouns",
"contact_id"
],
"user": [
"id",
"type"
],
"organization": [
"id",
"type",
"name"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [
"first_name",
"last_name",
"date_of_birth",
"pronouns"
],
"historical": true,
"relationship": false
},
{
"name": "order",
"schemas": [
{
"$id": "order",
"$ref": "entity",
"properties": {
"total": {
"type": "number"
},
"customer_id": {
"type": "string"
}
}
}
],
"hierarchy": [
"order",
"entity"
],
"fields": [
"id",
"type",
"total",
"customer_id",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"order": [
"id",
"type",
"total",
"customer_id"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [
"id"
],
"historical": true,
"relationship": false
},
{
"name": "order_line",
"schemas": [
{
"$id": "order_line",
"$ref": "entity",
"properties": {
"order_id": {
"type": "string"
},
"product": {
"type": "string"
},
"price": {
"type": "number"
}
}
}
],
"hierarchy": [
"order_line",
"entity"
],
"fields": [
"id",
"type",
"order_id",
"product",
"price",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
],
"grouped_fields": {
"order_line": [
"id",
"type",
"order_id",
"product",
"price"
],
"entity": [
"id",
"type",
"created_at",
"created_by",
"modified_at",
"modified_by",
"archived"
]
},
"lookup_fields": [],
"historical": true,
"relationship": false
}
]
},
"tests": [
{
"description": "Should query by ID if provided, rather than looking up by fields",
"action": "merge",
"data": {
"id": "123",
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z"
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE t1.id = '123'",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '123', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '123', 'Doe', 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"type\":\"person\"}', '123', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"123\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"type\":\"person\"}}')"
]
}
},
{
"description": "Should execute a lookup based on defined lookup_fields because no ID is provided",
"action": "merge",
"data": {
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z"
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE \"first_name\" = 'John' AND \"last_name\" = 'Doe' AND \"date_of_birth\" = '1990-01-01T00:00:00Z' AND \"pronouns\" IS NULL",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '{{uuid:person_1}}', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('{{uuid:person_1}}', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('{{uuid:person_1}}', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '{{uuid:person_1}}', 'Doe', 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"type\":\"person\"}', '{{uuid:person_1}}', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"{{uuid:person_1}}\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"type\":\"person\"}}')"
]
}
},
{
"description": "Should explicitly null out fields provided as empty strings",
"action": "merge",
"data": {
"id": "123",
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z",
"pronouns": ""
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE t1.id = '123'",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '123', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"pronouns\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '123', 'Doe', NULL, 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"pronouns\":\"\",\"type\":\"person\"}', '123', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"123\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"pronouns\":\"\",\"type\":\"person\"}}')"
]
}
}
]
},
{
"description": "Nested Relationship Mapping",
"description": "Merger Execution",
"database": {
"puncs": [],
"enums": [
{
"id": "e-type-1",
"id": "11111111-1111-1111-1111-111111111111",
"type": "relation_type",
"enum": "relation_type",
"values": [
@ -603,7 +17,7 @@
],
"relations": [
{
"id": "r-order-customer",
"id": "22222222-2222-2222-2222-222222222222",
"type": "relation",
"constraint": "fk_order_customer",
"source_type": "order",
@ -617,7 +31,7 @@
"prefix": "customer"
},
{
"id": "r-order-lines",
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_order_line_order",
"source_type": "order_line",
@ -994,7 +408,76 @@
},
"tests": [
{
"description": "Should execute a 1:1 nested relation and cascade child IDs to parent",
"description": "Person insert with id (no lookup)",
"action": "merge",
"data": {
"id": "123",
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z"
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE t1.id = '123'",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '123', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '123', 'Doe', 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"type\":\"person\"}', '123', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"123\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"type\":\"person\"}}')"
]
}
},
{
"description": "Person insert with no id (lookup)",
"action": "merge",
"data": {
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z"
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE \"first_name\" = 'John' AND \"last_name\" = 'Doe' AND \"date_of_birth\" = '1990-01-01T00:00:00Z' AND \"pronouns\" IS NULL",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '{{uuid:person_1}}', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('{{uuid:person_1}}', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('{{uuid:person_1}}', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '{{uuid:person_1}}', 'Doe', 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"type\":\"person\"}', '{{uuid:person_1}}', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"{{uuid:person_1}}\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"type\":\"person\"}}')"
]
}
},
{
"description": "Should explicitly null out fields provided as empty strings",
"action": "merge",
"data": {
"id": "123",
"type": "person",
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1990-01-01T00:00:00Z",
"pronouns": ""
},
"expect": {
"success": true,
"sql": [
"SELECT to_jsonb(t1.*) || to_jsonb(t2.*) || to_jsonb(t3.*) || to_jsonb(t4.*) FROM agreego.\"person\" t1 LEFT JOIN agreego.\"user\" t2 ON t2.id = t1.id LEFT JOIN agreego.\"organization\" t3 ON t3.id = t1.id LEFT JOIN agreego.\"entity\" t4 ON t4.id = t1.id WHERE t1.id = '123'",
"INSERT INTO agreego.\"entity\" (\"created_at\", \"created_by\", \"id\", \"modified_at\", \"modified_by\", \"type\") VALUES ('{{timestamp}}', '00000000-0000-0000-0000-000000000000', '123', '{{timestamp}}', '00000000-0000-0000-0000-000000000000', 'person')",
"INSERT INTO agreego.\"organization\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"user\" (\"id\", \"type\") VALUES ('123', 'person')",
"INSERT INTO agreego.\"person\" (\"date_of_birth\", \"first_name\", \"id\", \"last_name\", \"pronouns\", \"type\") VALUES ('1990-01-01T00:00:00Z', 'John', '123', 'Doe', NULL, 'person')",
"INSERT INTO agreego.change (changes, entity_id, id, kind, modified_at, modified_by) VALUES ('{\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"last_name\":\"Doe\",\"pronouns\":\"\",\"type\":\"person\"}', '123', '{{uuid}}', 'create', '{{timestamp}}', '00000000-0000-0000-0000-000000000000')",
"SELECT pg_notify('entity', '{\"complete\":{\"created_at\":\"{{timestamp}}\",\"created_by\":\"00000000-0000-0000-0000-000000000000\",\"date_of_birth\":\"1990-01-01T00:00:00Z\",\"first_name\":\"John\",\"id\":\"123\",\"last_name\":\"Doe\",\"modified_at\":\"{{timestamp}}\",\"modified_by\":\"00000000-0000-0000-0000-000000000000\",\"pronouns\":\"\",\"type\":\"person\"}}')"
]
}
},
{
"description": "Order with a nested customer person",
"action": "merge",
"data": {
"type": "order",