diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-04 12:26:16 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-04 12:26:16 -0500 |
| commit | ea5636c51361b86d132d647ee3548d208394878e (patch) | |
| tree | a60ab847c7324417ca7de46e73d370ba2af90d05 /wttrin.el | |
| parent | b74b98f177d92d50ddbede900ba41212e07c5f63 (diff) | |
| download | emacs-wttrin-ea5636c51361b86d132d647ee3548d208394878e.tar.gz emacs-wttrin-ea5636c51361b86d132d647ee3548d208394878e.zip | |
test: add 50 tests for untested functions; fix nil crash in save-debug-data
Add 11 new test files covering wttrin--save-debug-data,
wttrin--buffer-cache-refresh, wttrin--mode-line-stop,
wttrin--mode-line-start, wttrin-query, wttrin-requery-force,
wttrin-mode-line-click, wttrin-mode-line-force-refresh,
wttrin-fetch-raw-string, wttrin-clear-cache, and wttrin-requery.
Fix bug in wttrin--save-debug-data where nil raw-string caused
(insert nil) crash — reachable when debug mode is on and fetch fails.
Refactor wttrin-requery: extract wttrin--requery-location so the
core kill-buffer-and-query logic is testable without mocking
completing-read.
267 tests total (was 217), all passing.
Diffstat (limited to 'wttrin.el')
| -rw-r--r-- | wttrin.el | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -305,6 +305,12 @@ CALLBACK is called with the weather data string when ready, or nil on error." (interactive) (quit-window t)) +(defun wttrin--requery-location (new-location) + "Kill current weather buffer and query NEW-LOCATION." + (when (get-buffer "*wttr.in*") + (kill-buffer "*wttr.in*")) + (wttrin-query new-location)) + (defun wttrin-requery () "Kill buffer and requery wttrin." (interactive) @@ -312,9 +318,7 @@ CALLBACK is called with the weather data string when ready, or nil on error." "Location Name: " wttrin-default-locations nil nil (when (= (length wttrin-default-locations) 1) (car wttrin-default-locations))))) - (when (get-buffer "*wttr.in*") - (kill-buffer "*wttr.in*")) - (wttrin-query new-location))) + (wttrin--requery-location new-location))) (defvar wttrin-mode-map (let ((map (make-sparse-keymap))) @@ -347,7 +351,7 @@ Returns the path to the saved file." (insert (format "Timestamp: %s\n" (format-time-string "%Y-%m-%d %H:%M:%S"))) (insert (format "wttrin-unit-system: %s\n" wttrin-unit-system)) (insert "\n--- Raw Response ---\n\n") - (insert raw-string)) + (insert (or raw-string "(nil — no data received)"))) (when (featurep 'wttrin-debug) (wttrin--debug-log "Debug data saved to: %s" filepath)) filepath)) |
