diff options
Diffstat (limited to 'lib/configuration/tests/path.t')
| -rw-r--r-- | lib/configuration/tests/path.t | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/lib/configuration/tests/path.t b/lib/configuration/tests/path.t new file mode 100644 index 0000000..1532643 --- /dev/null +++ b/lib/configuration/tests/path.t @@ -0,0 +1,161 @@ +Resolve a path from a content: each segment is the name of a reference field, +and the result is the target of the last segment. + + $ tests --path legalEntity entity.employee.country <<EOF + > { + > "list": [ + > { + > "id": "region_list", + > "field": [ { "name": "label", "label": {}, "type": "text" } ] + > }, + > { + > "id": "country_list", + > "field": [ + > { "name": "code", "label": {}, "type": "text" }, + > { + > "name": "region", + > "label": {}, + > "type": { "content": "region_list" } + > } + > ] + > } + > ], + > "content": [ + > { + > "id": "legalEntity", + > "section": [ + > { + > "field": [ + > { + > "name": "entity", + > "label": {}, + > "type": { "content": "entity" } + > } + > ] + > } + > ] + > }, + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { + > "name": "employee", + > "label": {}, + > "type": { "content": "employee" } + > } + > ] + > } + > ] + > }, + > { + > "id": "employee", + > "section": [ + > { + > "field": [ + > { "name": "name", "label": {}, "type": "text" }, + > { + > "name": "country", + > "label": {}, + > "type": { "content": "country_list" } + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + field country (reference -> list country_list) + +Intermediate segments resolve to the targeted content: + + $ tests --path legalEntity entity <<EOF + > { + > "content": [ + > { + > "id": "legalEntity", + > "section": [ + > { + > "field": [ + > { "name": "entity", "label": {}, "type": { "content": "entity" } } + > ] + > } + > ] + > }, + > { "id": "entity" } + > ] + > } + > EOF + field entity (reference -> content entity) + +The path can go through the fields of a list: + + $ tests --path legalEntity entity.employee.country.region <<EOF + > { + > "list": [ + > { "id": "region_list" }, + > { + > "id": "country_list", + > "field": [ + > { "name": "region", "label": {}, "type": { "content": "region_list" } } + > ] + > } + > ], + > "content": [ + > { + > "id": "legalEntity", + > "section": [ { "field": [ + > { "name": "entity", "label": {}, "type": { "content": "entity" } } + > ] } ] + > }, + > { + > "id": "entity", + > "section": [ { "field": [ + > { "name": "employee", "label": {}, "type": { "content": "employee" } } + > ] } ] + > }, + > { + > "id": "employee", + > "section": [ { "field": [ + > { "name": "country", "label": {}, "type": { "content": "country_list" } } + > ] } ] + > } + > ] + > } + > EOF + field region (reference -> list region_list) + +A segment that is not a reference field, or does not exist, does not resolve: + + $ tests --path legalEntity entity.employee.name <<EOF + > { + > "content": [ + > { + > "id": "legalEntity", + > "section": [ { "field": [ + > { "name": "entity", "label": {}, "type": { "content": "entity" } } + > ] } ] + > }, + > { + > "id": "entity", + > "section": [ { "field": [ + > { "name": "employee", "label": {}, "type": { "content": "employee" } } + > ] } ] + > }, + > { + > "id": "employee", + > "section": [ { "field": [ + > { "name": "name", "label": {}, "type": "text" } + > ] } ] + > } + > ] + > } + > EOF + field name (text) + + $ tests --path legalEntity unknown.path <<EOF + > { "content": [ { "id": "legalEntity" } ] } + > EOF + unresolved path unknown.path |
