summaryrefslogtreecommitdiff
path: root/lib/query/tests
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-04-30 09:16:03 +0200
committerSébastien Dailly <sebastien@dailly.me>2026-05-06 16:45:25 +0200
commit960d5b8f2728f71dd9ce038d527844d82ca2f0f2 (patch)
tree9a15dc43f91a0b58a3aaa10223bba35abf7ef5f2 /lib/query/tests
parenta5efd7d15b4d049a4ed539ed5d9c2f1037d00973 (diff)
Allow updates for existing contents
Diffstat (limited to 'lib/query/tests')
-rw-r--r--lib/query/tests/update.t99
1 files changed, 99 insertions, 0 deletions
diff --git a/lib/query/tests/update.t b/lib/query/tests/update.t
new file mode 100644
index 0000000..32c04bb
--- /dev/null
+++ b/lib/query/tests/update.t
@@ -0,0 +1,99 @@
+Test the update method of a content.
+
+The test create a content with four features:
+- text
+- integer
+- mono reference
+- multi references
+and each test start with a new content empty.
+
+ $ tests --update --help
+ Start the tests
+ --text <v> Set field with the value <v>
+ --integer <n> Set field with the value <n>
+ --reference <id> Set field with the id
+ --references <id,..> Set this list of values
+ --commit Commit this group of update
+ --clear <f> Clear the field <f>
+ -help Display this list of options
+ --help Display this list of options
+
+After each invocation (or after a commit), the test displays the values for the
+content. By default it is empty:
+
+ $ tests --update \
+ > --commit
+ {"reference":null,"integer":null,"text":null}
+
+The multivaluated field references is not displayed when there is no values.
+
+Any feature can be set using an argument with the same name:
+
+ $ tests --update \
+ > --integer 123
+ {"reference":null,"integer":123,"text":null}
+
+ $ tests --update \
+ > --text abc
+ {"reference":null,"integer":null,"text":"abc"}
+
+ $ tests --update \
+ > --reference 1
+ {"reference":1,"integer":null,"text":null}
+
+The multireferences values are displayed only when they are set.
+
+ $ tests --update \
+ > --references 1,2,3 \
+ {"reference":null,"integer":null,"text":null}
+ {"references":1}
+ {"references":2}
+ {"references":3}
+
+The "commit" argument can be used to update the content at a given state
+
+ $ tests --update \
+ > --integer 123 \
+ > --text abc \
+ > --references 1 \
+ > --commit \
+ > --reference 1
+ {"reference":null,"integer":123,"text":"abc"}
+ {"references":1}
+ {"reference":1,"integer":123,"text":"abc"}
+ {"references":1}
+
+A field can be explicitally set empty. There is a difference between not
+updating a field (changing nothing) and setting the field to empty:
+
+ $ tests --update \
+ > --integer 123 \
+ > --text abc \
+ > --commit \
+ > --clear integer
+ {"reference":null,"integer":123,"text":"abc"}
+ {"reference":null,"integer":null,"text":"abc"}
+
+ $ tests --update \
+ > --references 1,2,3 \
+ > --commit \
+ > --clear references
+ {"reference":null,"integer":null,"text":null}
+ {"references":1}
+ {"references":2}
+ {"references":3}
+ {"reference":null,"integer":null,"text":null}
+
+There is no duplicates values in the external references, a new update replace
+the existing values.
+
+ $ tests --update \
+ > --references 1,2 \
+ > --commit \
+ > --references 1,3
+ {"reference":null,"integer":null,"text":null}
+ {"references":1}
+ {"references":2}
+ {"reference":null,"integer":null,"text":null}
+ {"references":1}
+ {"references":3}