diff options
Diffstat (limited to 'lib/model/tests')
| -rw-r--r-- | lib/model/tests/dune | 11 | ||||
| -rw-r--r-- | lib/model/tests/parent.t | 91 |
2 files changed, 102 insertions, 0 deletions
diff --git a/lib/model/tests/dune b/lib/model/tests/dune new file mode 100644 index 0000000..c5913da --- /dev/null +++ b/lib/model/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/model/tests/parent.t b/lib/model/tests/parent.t new file mode 100644 index 0000000..8e77578 --- /dev/null +++ b/lib/model/tests/parent.t @@ -0,0 +1,91 @@ + +A root content does not have any parent + + $ tests -parent "entity" <<EOF + > { + > "content": [ + > { + > "id": "entity" + > } + > ] + > } + > EOF + [No parent] + +A root content is the root of itself + + $ tests -parent -root "entity" <<EOF + > { + > "content": [ + > { + > "id": "entity" + > } + > ] + > } + > EOF + "entity" + +The parent of a subcontent shall never been None, and will target the container + + $ tests -parent "details" <<EOF + > { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "details" + > } + > ] + > } + > ] + > } + > EOF + "entity" + +The parent element can be a subcontent itself + + $ tests -parent "level2" <<EOF + > { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "level1", + > "subcontent": [ + > { + > "id": "level2" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + "level1" + +The root element is the top content + + $ tests -parent -root "level2" <<EOF + > { + > "content": [ + > { + > "id": "entity", + > "subcontent": [ + > { + > "id": "level1", + > "subcontent": [ + > { + > "id": "level2" + > } + > ] + > } + > ] + > } + > ] + > } + > EOF + "entity" + |
