summaryrefslogtreecommitdiff
path: root/lib/configuration
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-19 13:26:42 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-19 13:26:42 +0100
commitfb75994d097cb1d6a1a0ea871c2d2213aa4e3c31 (patch)
tree2e783d1472971c1823ec6e7a9cb484ebda2b0b43 /lib/configuration
parentd1047791e9e25bc5a30ffc62f31c3d898843f042 (diff)
Path over contents evaluation
Diffstat (limited to 'lib/configuration')
-rw-r--r--lib/configuration/tests/path.t161
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