From be0d09e2cb91ef391d7455334fc5ed15d6f5649a Mon Sep 17 00:00:00 2001 From: Christopher Warner Date: Sat, 10 Oct 2026 18:49:01 -0400 Subject: feat: update existing Apple Notes by title instead of duplicating Add `icloud-note update` that finds a note by title and replaces its content in place so revision requests do not create a second note. Co-authored-by: Cursor --- tests/cli.test.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/cli.test.sh') 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)" -- cgit v1.2.3