diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-21 11:23:41 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-21 11:23:41 +0100 |
| commit | ce13c93cf14cb71894481b0303a7058a72a6f4ce (patch) | |
| tree | bd93186a65f6645cb4401f188d266d743cc2fde7 /lib/value/tests | |
| parent | 172a02b80d8dbdcfe09129d7fa76015bb5ec4d79 (diff) | |
Load values from the database
Diffstat (limited to 'lib/value/tests')
| -rw-r--r-- | lib/value/tests/dune | 11 | ||||
| -rw-r--r-- | lib/value/tests/load.t | 41 |
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/value/tests/dune b/lib/value/tests/dune new file mode 100644 index 0000000..c5913da --- /dev/null +++ b/lib/value/tests/dune @@ -0,0 +1,11 @@ +; Add the test library in the path + +(env + (_ + (binaries %{project_root}/test/tests.exe))) + +; And depend of it. The binary will be available in the +; cram tests under the name "tests" + +(cram + (deps %{bin:tests})) diff --git a/lib/value/tests/load.t b/lib/value/tests/load.t new file mode 100644 index 0000000..e20860a --- /dev/null +++ b/lib/value/tests/load.t @@ -0,0 +1,41 @@ +High level test of [Value.load]: two rows are inserted in the table of the +content given as argument (the configuration is read on the standard input), +loaded as values with [Value.load] and printed with [Value.pp] — the primary +key and every field, as read back as typed data with [Value.get]. + + $ tests --load "entity" <<EOF + > { + > "list": [ + > { + > "id": "country_list", + > "field": [ + > { "name": "code", "label": {}, "type": "text" } + > ] + > } + > ], + > "content": [ + > { + > "id": "entity", + > "section": [ + > { + > "field": [ + > { "name": "name", "label": {}, "type": "text" }, + > { "name": "year", "label": {}, "type": "integer" }, + > { "name": "country", "label": {}, "type": { "content": "country_list" } }, + > { + > "name": "aliases", + > "label": {}, + > "type": { "content": "country_list", "multivaluated": true } + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + row 1: + {id = 1; aliases = [1, 2]; country = 1; name = "name-1"; year = 1} + row 2: + {id = 2; aliases = [2]; country = 1; name = "name-2"; year = 2} + |
