aboutsummaryrefslogtreecommitdiff
path: root/tests/test-wttrin-use-current-location.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-01 13:51:28 -0400
committerCraig Jennings <c@cjennings.net>2026-07-01 13:51:28 -0400
commitf2d3f6c6586ede7f757ca74ea699982562f069a7 (patch)
tree86f292b6ad19c2affd067d6ba13ce3865629a7c0 /tests/test-wttrin-use-current-location.el
parentb1aca874b9a2b5282c0cc83bd4fece981a94e19c (diff)
downloademacs-wttrin-f2d3f6c6586ede7f757ca74ea699982562f069a7.tar.gz
emacs-wttrin-f2d3f6c6586ede7f757ca74ea699982562f069a7.zip
fix: keep a d-set favorite from reverting to the init value on restart
wttrin-favorite-location did two jobs: a defcustom the user sets in init, and the savehist-persisted value that `d`/make-default mutated. Setting it in init (setopt) clobbered the `d` choice on every startup. So a favorite promoted with `d` reverted to the init value after a restart, and the mode-line showed the wrong location's weather. wttrin-saved-locations had the same defect. I split the two roles. The defcustoms stay as the init-set base. New savehist-persisted runtime vars, wttrin--favorite-override and wttrin--saved-locations-runtime, hold what `d`, save, rename, remove, and the geolocation commands write. Reads go through resolvers: wttrin--favorite-location returns the override or the configured favorite, and wttrin--saved-locations overlays the runtime directory on the configured one (runtime wins on a name collision). Init and `d` now write different variables, so neither clobbers the other. Removing a saved location that only comes from init can't delete it, since the runtime removal has nothing to touch. The command now says so instead of reporting a removal that didn't happen. There's no automatic migration. A favorite set in init is unaffected, and a favorite set only with `d` before this version is re-set once with `d`. The README documents the behavior.
Diffstat (limited to 'tests/test-wttrin-use-current-location.el')
-rw-r--r--tests/test-wttrin-use-current-location.el18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/test-wttrin-use-current-location.el b/tests/test-wttrin-use-current-location.el
index 4b61657..d7d0ea6 100644
--- a/tests/test-wttrin-use-current-location.el
+++ b/tests/test-wttrin-use-current-location.el
@@ -18,14 +18,20 @@
(defvar test-wttrin-use-current-location--saved nil
"Snapshot of `wttrin-favorite-location' restored in teardown.")
+(defvar test-wttrin-use-current-location--saved-override nil
+ "Snapshot of `wttrin--favorite-override' restored in teardown.")
+
(defun test-wttrin-use-current-location-setup ()
- "Snapshot `wttrin-favorite-location' and clear it."
+ "Snapshot the configured favorite and the runtime override, clearing both."
(setq test-wttrin-use-current-location--saved wttrin-favorite-location)
- (setq wttrin-favorite-location nil))
+ (setq test-wttrin-use-current-location--saved-override wttrin--favorite-override)
+ (setq wttrin-favorite-location nil)
+ (setq wttrin--favorite-override nil))
(defun test-wttrin-use-current-location-teardown ()
- "Restore `wttrin-favorite-location'."
- (setq wttrin-favorite-location test-wttrin-use-current-location--saved))
+ "Restore the configured favorite and the runtime override."
+ (setq wttrin-favorite-location test-wttrin-use-current-location--saved)
+ (setq wttrin--favorite-override test-wttrin-use-current-location--saved-override))
;;; Normal Cases
@@ -37,7 +43,7 @@
(cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t))
((symbol-function 'message) (lambda (&rest _) nil)))
(wttrin-use-current-location))
- (should (eq t wttrin-favorite-location)))
+ (should (eq t (wttrin--favorite-location))))
(test-wttrin-use-current-location-teardown)))
(ert-deftest test-wttrin-use-current-location-normal-decline-leaves-unchanged ()
@@ -69,7 +75,7 @@ location immediately rather than at the next scheduled fetch."
((symbol-function 'wttrin--mode-line-set-placeholder)
(lambda () nil)))
(wttrin-use-current-location))
- (should (eq t wttrin-favorite-location))
+ (should (eq t (wttrin--favorite-location)))
(should fetched))
(test-wttrin-use-current-location-teardown)))