Files
jspg/fixtures/merge.json
Alex Groleau e026e82f65 test(jspg): rename items fixture to array and resolve unused HashMap warning
- Rename fixtures/items.json to fixtures/array.json to better reflect array testing constraints.
- Update reference paths in src/tests/fixtures.rs and across other fixture JSON files.
- Remove unused HashMap import in src/validator/rules/dict.rs to resolve the compiler warning.
2026-06-23 20:17:03 -04:00

338 lines
7.3 KiB
JSON

[
{
"description": "merging: properties accumulate",
"database": {
"types": [
{
"name": "base_0",
"schemas": {
"base_0": {
"properties": {
"base_prop": {
"type": "string"
}
}
}
}
},
{
"name": "merge_0_0",
"schemas": {
"merge_0_0": {
"type": "base_0",
"properties": {
"child_prop": {
"type": "string"
}
}
}
}
}
]
},
"tests": [
{
"description": "valid with both properties",
"data": {
"base_prop": "a",
"child_prop": "b"
},
"schema_id": "merge_0_0",
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "invalid when base property has wrong type",
"data": {
"base_prop": 1,
"child_prop": "b"
},
"schema_id": "merge_0_0",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "INVALID_TYPE",
"values": {
"expected": "string"
},
"details": {
"path": "base_prop",
"schema": "merge_0_0"
}
}
]
}
}
]
},
{
"description": "merging: required fields accumulate",
"database": {
"types": [
{
"name": "base_1",
"schemas": {
"base_1": {
"properties": {
"a": {
"type": "string"
}
},
"required": [
"a"
]
}
}
},
{
"name": "merge_1_0",
"schemas": {
"merge_1_0": {
"type": "base_1",
"properties": {
"b": {
"type": "string"
}
},
"required": [
"b"
]
}
}
}
]
},
"tests": [
{
"description": "valid when both present",
"data": {
"a": "ok",
"b": "ok"
},
"schema_id": "merge_1_0",
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "invalid when base required missing",
"data": {
"b": "ok"
},
"schema_id": "merge_1_0",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"values": {
"field_name": "a"
},
"details": {
"path": "a",
"schema": "merge_1_0"
}
}
]
}
},
{
"description": "invalid when child required missing",
"data": {
"a": "ok"
},
"schema_id": "merge_1_0",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "REQUIRED_FIELD_MISSING",
"values": {
"field_name": "b"
},
"details": {
"path": "b",
"schema": "merge_1_0"
}
}
]
}
}
]
},
{
"description": "merging: dependencies accumulate",
"database": {
"types": [
{
"name": "base_2",
"schemas": {
"base_2": {
"properties": {
"trigger": {
"type": "string"
},
"base_dep": {
"type": "string"
}
},
"dependencies": {
"trigger": [
"base_dep"
]
}
}
}
},
{
"name": "merge_2_0",
"schemas": {
"merge_2_0": {
"type": "base_2",
"properties": {
"child_dep": {
"type": "string"
}
},
"dependencies": {
"trigger": [
"child_dep"
]
}
}
}
}
]
},
"tests": [
{
"description": "valid with all deps",
"data": {
"trigger": "go",
"base_dep": "ok",
"child_dep": "ok"
},
"schema_id": "merge_2_0",
"action": "validate",
"expect": {
"success": true
}
},
{
"description": "invalid missing base dep",
"data": {
"trigger": "go",
"child_dep": "ok"
},
"schema_id": "merge_2_0",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "DEPENDENCY_MISSING",
"values": {
"required_property": "base_dep",
"property_name": "trigger"
},
"details": {
"path": "",
"schema": "merge_2_0"
}
}
]
}
},
{
"description": "invalid missing child dep",
"data": {
"trigger": "go",
"base_dep": "ok"
},
"schema_id": "merge_2_0",
"action": "validate",
"expect": {
"success": false,
"errors": [
{
"code": "DEPENDENCY_MISSING",
"values": {
"required_property": "child_dep",
"property_name": "trigger"
},
"details": {
"path": "",
"schema": "merge_2_0"
}
}
]
}
}
]
},
{
"description": "merging: form and display do NOT merge",
"database": {
"types": [
{
"name": "base_3",
"schemas": {
"base_3": {
"properties": {
"a": {
"type": "string"
},
"b": {
"type": "string"
}
},
"form": [
"a",
"b"
]
}
}
},
{
"name": "merge_3_0",
"schemas": {
"merge_3_0": {
"type": "base_3",
"properties": {
"c": {
"type": "string"
}
},
"form": [
"c"
]
}
}
}
]
},
"tests": [
{
"description": "child schema validation",
"data": {
"a": "ok",
"b": "ok",
"c": "ok"
},
"comment": "Verifies validator handles the unmerged metadata correctly (ignores it or handles replacement)",
"schema_id": "merge_3_0",
"action": "validate",
"expect": {
"success": true
}
}
]
}
]