summaryrefslogtreecommitdiff
path: root/tests/test-wttrin--handle-fetch-callback.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-17 19:14:14 -0600
committerCraig Jennings <c@cjennings.net>2026-02-17 19:14:14 -0600
commit28b7e4cecadce207d532b8d42346c3823450a35f (patch)
tree4d8772206e10c59762ae1e60343d4bc8dded77b5 /tests/test-wttrin--handle-fetch-callback.el
parentbf989bb594680eb2e3b69f55752353aa33cb47bb (diff)
downloademacs-wttrin-28b7e4cecadce207d532b8d42346c3823450a35f.tar.gz
emacs-wttrin-28b7e4cecadce207d532b8d42346c3823450a35f.zip
refactor: tests: standardize naming, consolidate files, and expand testutil
- Expand testutil-wttrin.el with shared fixtures and macros (testutil-wttrin-with-clean-weather-buffer, testutil-wttrin-mock-http-response, sample ANSI/weather constants) - Consolidate cache tests: port unique tests from cleanup-cache-constants and cleanup-cache-refactored into cleanup-cache-if-needed, delete obsolete files - Extract startup-delay tests into dedicated file - Add setup/teardown and (require 'testutil-wttrin) to all test files - Rename all 160 tests to follow test-<module>-<category>-<scenario>-<expected-result> convention - Rename integration test file and add detailed docstrings - Update Makefile glob to discover new integration test naming pattern Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tests/test-wttrin--handle-fetch-callback.el')
-rw-r--r--tests/test-wttrin--handle-fetch-callback.el37
1 files changed, 24 insertions, 13 deletions
diff --git a/tests/test-wttrin--handle-fetch-callback.el b/tests/test-wttrin--handle-fetch-callback.el
index 203a232..ccd455e 100644
--- a/tests/test-wttrin--handle-fetch-callback.el
+++ b/tests/test-wttrin--handle-fetch-callback.el
@@ -10,10 +10,21 @@
(require 'ert)
(require 'wttrin)
+(require 'testutil-wttrin)
+
+;;; Setup and Teardown
+
+(defun test-wttrin--handle-fetch-callback-setup ()
+ "Setup for handle-fetch-callback tests."
+ (testutil-wttrin-setup))
+
+(defun test-wttrin--handle-fetch-callback-teardown ()
+ "Teardown for handle-fetch-callback tests."
+ (testutil-wttrin-teardown))
;;; Normal Cases
-(ert-deftest test-wttrin--handle-fetch-callback-normal-successful-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-successful-response-calls-callback-with-data ()
"Test handling successful response with callback invocation."
(let ((callback-called nil)
(callback-data nil))
@@ -29,7 +40,7 @@
(should callback-called)
(should (string= "Weather: ☀️ Sunny" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-normal-empty-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-empty-response-calls-callback-with-empty ()
"Test handling empty but successful response."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -44,7 +55,7 @@
(should callback-called)
(should (string= "" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-normal-large-response ()
+(ert-deftest test-wttrin--handle-fetch-callback-normal-large-response-calls-callback-with-full-data ()
"Test handling large response data."
(let ((callback-called nil)
(callback-data nil)
@@ -63,7 +74,7 @@
;;; Boundary Cases
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-nil-status ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-nil-status-calls-callback ()
"Test handling nil status (successful response)."
(let ((callback-called nil))
(cl-letf (((symbol-function 'wttrin--extract-response-body)
@@ -75,7 +86,7 @@
(should callback-called))))
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-empty-status-plist ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-empty-status-plist-calls-callback ()
"Test handling empty status plist."
(let ((callback-called nil)
(callback-data nil))
@@ -90,7 +101,7 @@
(should callback-called)
(should (string= "data" callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-boundary-status-with-other-keys ()
+(ert-deftest test-wttrin--handle-fetch-callback-boundary-status-with-other-keys-calls-callback ()
"Test handling status with various keys but no error."
(let ((callback-called nil))
(cl-letf (((symbol-function 'wttrin--extract-response-body)
@@ -104,7 +115,7 @@
;;; Error Cases
-(ert-deftest test-wttrin--handle-fetch-callback-error-network-error ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-network-error-calls-callback-with-nil ()
"Test handling network error in status."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -117,7 +128,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-http-404 ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-http-404-calls-callback-with-nil ()
"Test handling HTTP error status."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -130,7 +141,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-timeout ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-timeout-calls-callback-with-nil ()
"Test handling timeout error."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -143,7 +154,7 @@
(should callback-called)
(should (null callback-data))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-callback-throws ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-callback-throws-does-not-propagate ()
"Test handling errors thrown by user callback."
(let ((callback-called nil)
(error-caught nil))
@@ -163,7 +174,7 @@
;; Error should be caught and handled, not propagated
(should-not error-caught))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-extract-body-throws ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-extract-body-throws-propagates-error ()
"Test that errors during body extraction are not caught and propagate."
(let ((callback-called nil)
(error-caught nil))
@@ -181,7 +192,7 @@
(should-not callback-called)
(should error-caught))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-nil-data-from-extract ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-nil-data-from-extract-calls-callback-with-nil ()
"Test handling nil data returned from extraction."
(let ((callback-called nil)
(callback-data 'not-nil))
@@ -196,7 +207,7 @@
(should callback-called)
(should (null callback-data)))))
-(ert-deftest test-wttrin--handle-fetch-callback-error-multiple-error-keys ()
+(ert-deftest test-wttrin--handle-fetch-callback-error-multiple-error-keys-calls-callback-with-nil ()
"Test handling status with multiple error indicators."
(let ((callback-called nil)
(callback-data 'not-nil))