aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/test-mail-notify.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-13 17:21:31 +0200
committerDanilo M. <danix@danix.xyz>2026-09-13 17:21:31 +0200
commitb79f34725fca2eb43bf1377e43b9aba4ef29afeb (patch)
tree312436053ef54dae7e1a20c8904a5c886b518eb6 /mail-overview/test-mail-notify.sh
parent73539f9d3863013d8a6baebfd05da0b10b4190c7 (diff)
downloadquickshell-b79f34725fca2eb43bf1377e43b9aba4ef29afeb.tar.gz
quickshell-b79f34725fca2eb43bf1377e43b9aba4ef29afeb.zip
feat(mail-overview): track the notified revision
Stores the database UUID beside the revision, because notmuch revisions only compare within one database and a rebuild restarts the counter. Missing, corrupt or mismatched state reports nothing, which the caller treats as seed-silently: with no floor, lastmod:0.. matches every unread message and startup becomes a wall of popups.
Diffstat (limited to 'mail-overview/test-mail-notify.sh')
-rwxr-xr-xmail-overview/test-mail-notify.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/mail-overview/test-mail-notify.sh b/mail-overview/test-mail-notify.sh
index fccf4b3..95e971d 100755
--- a/mail-overview/test-mail-notify.sh
+++ b/mail-overview/test-mail-notify.sh
@@ -111,5 +111,30 @@ check "malformed json yields an empty body rather than an error" \
"" \
"$(build_body 'not json at all' 1 2>/dev/null)"
+# A scratch state file, removed at exit. Never the real one: that is the
+# user's live notification position, and a test must not move it.
+tmpstate="$(mktemp)"
+trap 'rm -f "$tmpstate"' EXIT
+STATE="$tmpstate"
+
+rm -f "$tmpstate"
+check "a missing state file reports no previous revision" \
+ "" "$(read_prev_rev "uuid-a")"
+
+write_state "uuid-a" 500
+check "a revision written is a revision read back" \
+ "500" "$(read_prev_rev "uuid-a")"
+
+check "a different database UUID discards the revision" \
+ "" "$(read_prev_rev "uuid-b")"
+
+printf 'garbage not a state file\n' > "$tmpstate"
+check "an unparseable state file reports no previous revision" \
+ "" "$(read_prev_rev "uuid-a")"
+
+write_state "uuid-a" 600
+check "a rewrite replaces rather than appends" \
+ "1" "$(wc -l < "$tmpstate")"
+
printf '\n%d passed, %d failed\n' "$pass" "$fail"
[[ "$fail" -eq 0 ]]