From 0bbed459fb60f1b9ebe0e137527aa44b75c4835e Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 13:27:39 -0500 Subject: fix: debug-wttrin-show-raw serves cached data instead of fetching A debug command should show what the API currently returns, not a cached copy. Bind wttrin--force-refresh to t so the fetch always bypasses the cache. --- tests/test-debug-wttrin-show-raw.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/test-debug-wttrin-show-raw.el') diff --git a/tests/test-debug-wttrin-show-raw.el b/tests/test-debug-wttrin-show-raw.el index b447292..67e50ca 100644 --- a/tests/test-debug-wttrin-show-raw.el +++ b/tests/test-debug-wttrin-show-raw.el @@ -100,5 +100,22 @@ (should (get-buffer "*wttrin-debug*"))) (test-debug-wttrin-show-raw-teardown))) +(ert-deftest test-debug-wttrin-show-raw-normal-always-fetches-fresh () + "A debug command should always fetch from the API, not serve cached data. +When debugging, the user needs to see what the API currently returns." + (test-debug-wttrin-show-raw-setup) + (unwind-protect + (let ((force-refresh-was-set nil)) + ;; Seed cache so there IS data to serve + (testutil-wttrin-add-to-cache "Paris" "old cached data" 300) + (cl-letf (((symbol-function 'wttrin--get-cached-or-fetch) + (lambda (_location callback) + (setq force-refresh-was-set wttrin--force-refresh) + (funcall callback "fresh from API")))) + (debug-wttrin-show-raw "Paris") + ;; Force-refresh should have been active during the fetch + (should force-refresh-was-set))) + (test-debug-wttrin-show-raw-teardown))) + (provide 'test-debug-wttrin-show-raw) ;;; test-debug-wttrin-show-raw.el ends here -- cgit v1.2.3