summaryrefslogtreecommitdiff
path: root/tests/cli.test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cli.test.sh')
-rwxr-xr-xtests/cli.test.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/cli.test.sh b/tests/cli.test.sh
index 6aeef87..083f73a 100755
--- a/tests/cli.test.sh
+++ b/tests/cli.test.sh
@@ -17,6 +17,7 @@ pass() { echo "ok: $*"; }
# --- help ---
out="$("${CLI[@]}" 2>&1)" || fail "no-args help failed"
[[ "$out" == *"icloud-note create"* ]] || fail "help missing create: $out"
+[[ "$out" == *"icloud-note update"* ]] || fail "help missing update: $out"
[[ "$out" == *"headless"* ]] || fail "help should say create/status are headless"
[[ "$out" != *"--headed"* ]] || fail "help must not advertise --headed"
[[ "$out" == *"$ICLOUD_NOTES_CONFIG"* ]] || fail "help should show ICLOUD_NOTES_CONFIG path"
@@ -66,6 +67,27 @@ out="$("${CLI[@]}" create "Positional" --body "x" 2>&1)" || fail "positional cre
[[ "$out" == *'title="Positional"'* ]] || fail "positional title: $out"
pass "create positional title"
+# --- update validation / dry-run ---
+set +e
+err="$("${CLI[@]}" update --body "x" 2>&1)"
+code=$?
+set -e
+[[ "$code" -ne 0 ]] || fail "update without title should fail"
+[[ "$err" == *"Provide --title"* ]] || fail "update empty title message: $err"
+pass "update requires title"
+
+out="$("${CLI[@]}" update --title "Existing" --body "revised" 2>&1)" \
+ || fail "update dry-run failed"
+[[ "$out" == *'dry-run: would update note match="Existing"'* ]] || fail "update dry-run: $out"
+[[ "$out" == *'title="Existing"'* ]] || fail "update dry-run title: $out"
+pass "update dry-run"
+
+out="$("${CLI[@]}" update --match-title "Old" --title "New" --body "x" 2>&1)" \
+ || fail "update match-title dry-run failed"
+[[ "$out" == *'match="Old"'* ]] || fail "match-title: $out"
+[[ "$out" == *'title="New"'* ]] || fail "new title in update dry-run: $out"
+pass "update --match-title dry-run"
+
# --- status dry-run without session ---
set +e
err="$("${CLI[@]}" status 2>&1)"