Files
jspg/fixtures/database.json

410 lines
9.7 KiB
JSON

[
{
"description": "Edge missing - 0 relations",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "org",
"module": "test",
"source": "test",
"hierarchy": [
"org"
],
"variations": [
"org"
],
"schemas": [
{
"$id": "full.org",
"type": "object",
"properties": {
"missing_users": {
"type": "array",
"items": {
"$ref": "full.user"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "user",
"module": "test",
"source": "test",
"hierarchy": [
"user"
],
"variations": [
"user"
],
"schemas": [
{
"$id": "full.user",
"type": "object",
"properties": {}
}
]
}
],
"relations": []
},
"tests": [
{
"description": "throws EDGE_MISSING when 0 relations exist between org and user",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "EDGE_MISSING"
}
]
}
}
]
},
{
"description": "Edge missing - array cardinality rejection",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "parent",
"module": "test",
"source": "test",
"hierarchy": [
"parent"
],
"variations": [
"parent"
],
"schemas": [
{
"$id": "full.parent",
"type": "object",
"properties": {
"children": {
"type": "array",
"items": {
"$ref": "full.child"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "child",
"module": "test",
"source": "test",
"hierarchy": [
"child"
],
"variations": [
"child"
],
"schemas": [
{
"$id": "full.child",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_parent_child",
"source_type": "parent",
"source_columns": [
"child_id"
],
"destination_type": "child",
"destination_columns": [
"id"
]
}
]
},
"tests": [
{
"description": "throws EDGE_MISSING because a Forward scaler edge cannot mathematically fulfill an Array collection",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "EDGE_MISSING"
}
]
}
}
]
},
{
"description": "Ambiguous type relations - multiple unprefixed relations",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "invoice",
"module": "test",
"source": "test",
"hierarchy": [
"invoice"
],
"variations": [
"invoice"
],
"schemas": [
{
"$id": "full.invoice",
"type": "object",
"properties": {
"activities": {
"type": "array",
"items": {
"$ref": "full.activity"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "activity",
"module": "test",
"source": "test",
"hierarchy": [
"activity"
],
"variations": [
"activity"
],
"schemas": [
{
"$id": "full.activity",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_activity_invoice_1",
"source_type": "activity",
"source_columns": [
"invoice_id_1"
],
"destination_type": "invoice",
"destination_columns": [
"id"
]
},
{
"id": "44444444-4444-4444-4444-444444444444",
"type": "relation",
"constraint": "fk_activity_invoice_2",
"source_type": "activity",
"source_columns": [
"invoice_id_2"
],
"destination_type": "invoice",
"destination_columns": [
"id"
]
}
]
},
"tests": [
{
"description": "throws AMBIGUOUS_TYPE_RELATIONS when fallback encounters multiple naked constraints",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "AMBIGUOUS_TYPE_RELATIONS",
"details": {
"cause": "Multiple conflicting constraints found matching prefixes",
"context": [
{
"constraint": "fk_activity_invoice_1"
},
{
"constraint": "fk_activity_invoice_2"
}
]
}
}
]
}
}
]
},
{
"description": "Ambiguous type relations - M:M twin deduction failure",
"database": {
"types": [
{
"id": "11111111-1111-1111-1111-111111111111",
"type": "type",
"name": "actor",
"module": "test",
"source": "test",
"hierarchy": [
"actor"
],
"variations": [
"actor"
],
"schemas": [
{
"$id": "full.actor",
"type": "object",
"properties": {
"ambiguous_edge": {
"type": "array",
"items": {
"$ref": "empty.junction"
}
}
}
}
]
},
{
"id": "22222222-2222-2222-2222-222222222222",
"type": "type",
"name": "junction",
"module": "test",
"source": "test",
"hierarchy": [
"junction"
],
"variations": [
"junction"
],
"schemas": [
{
"$id": "empty.junction",
"type": "object",
"properties": {}
}
]
}
],
"relations": [
{
"id": "33333333-3333-3333-3333-333333333333",
"type": "relation",
"constraint": "fk_junction_source_actor",
"source_type": "junction",
"source_columns": [
"source_id"
],
"destination_type": "actor",
"destination_columns": [
"id"
],
"prefix": "source"
},
{
"id": "44444444-4444-4444-4444-444444444444",
"type": "relation",
"constraint": "fk_junction_target_actor",
"source_type": "junction",
"source_columns": [
"target_id"
],
"destination_type": "actor",
"destination_columns": [
"id"
],
"prefix": "target"
}
]
},
"tests": [
{
"description": "throws AMBIGUOUS_TYPE_RELATIONS because child doesn't explicitly expose 'source' or 'target' for twin deduction",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "AMBIGUOUS_TYPE_RELATIONS",
"details": {
"cause": "Multiple conflicting constraints found matching prefixes",
"context": [
{
"constraint": "fk_junction_source_actor"
},
{
"constraint": "fk_junction_target_actor"
}
]
}
}
]
}
}
]
},
{
"description": "Database type parse failed",
"database": {
"types": [
{
"id": [
"must",
"be",
"string",
"to",
"fail"
],
"type": "type",
"name": "failure",
"module": "test",
"source": "test",
"hierarchy": [
"failure"
],
"variations": [
"failure"
]
}
]
},
"tests": [
{
"description": "throws DATABASE_TYPE_PARSE_FAILED when metadata completely fails Serde typing",
"action": "compile",
"expect": {
"success": false,
"errors": [
{
"code": "DATABASE_TYPE_PARSE_FAILED"
}
]
}
}
]
}
]