diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-14 00:07:06 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-14 00:07:06 -0500 |
| commit | 703b4841253ca610e9b50a8e8519863eaf22a6b2 (patch) | |
| tree | 162e9cff886d7e8e6bdca41113dc245cee438d61 /tests/test-signal-config.el | |
| parent | 03a1f26b2879f678a48c036a9e6f4b9ace864c3b (diff) | |
| download | dotemacs-703b4841253ca610e9b50a8e8519863eaf22a6b2.tar.gz dotemacs-703b4841253ca610e9b50a8e8519863eaf22a6b2.zip | |
fix(signal): honor the cache-clear promise and mark empty fetches warm
Two picker-cache bugs from the config audit, verified against current code first.
The cache docstring promised clearing on signel-stop, but nothing cleared it, so a stale contact list survived a relink or reconnect. I advised a named clear function :after signel-stop, which makes the docstring true.
An empty listContacts result cached nil, indistinguishable from a cold cache, so a zero-contact account re-ran the picker's blocking fetch (up to the 3s timeout) on every open. The fetch now caches an empty sentinel and the picker reads through cj/signel--cached-contacts. One existing test pinned the nil behavior and now asserts the sentinel instead.
Diffstat (limited to 'tests/test-signal-config.el')
| -rw-r--r-- | tests/test-signal-config.el | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/test-signal-config.el b/tests/test-signal-config.el index 7556efdb..f8bf4410 100644 --- a/tests/test-signal-config.el +++ b/tests/test-signal-config.el @@ -251,9 +251,12 @@ and stores the (LABEL . RECIPIENT) alist in `cj/signel--contact-cache'." (should (equal cj/signel--contact-cache '(("Alice (+15555550100)" . "+15555550100")))))) -(ert-deftest test-signal-config-fetch-contacts-empty-result-clears-cache () - "Boundary: an empty listContacts result populates the cache as nil, -distinct from a failure path (which never invokes the success callback)." +(ert-deftest test-signal-config-fetch-contacts-empty-result-caches-sentinel () + "Boundary: an empty listContacts result caches the `empty' sentinel. +nil would read as a cold cache and re-run the picker's blocking fetch on +every open; the sentinel marks warm-but-empty. Still distinct from a +failure path, which never invokes the success callback. (This test +formerly pinned the nil behavior -- the 2026-06 audit's F2 bug.)" (let (sent-callback) (cl-letf (((symbol-function 'signel--send-rpc) (lambda (_method _params _target callback) @@ -261,7 +264,7 @@ distinct from a failure path (which never invokes the success callback)." (setq cj/signel--contact-cache '(("stale" . "+10000000000"))) (cj/signel--fetch-contacts) (funcall sent-callback [])) - (should-not cj/signel--contact-cache))) + (should (eq cj/signel--contact-cache 'empty)))) ;;; cj/signel-refresh-contacts |
