summaryrefslogtreecommitdiff
path: root/tests/test-wttrin--cleanup-cache-constants.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-11-08 13:16:42 -0600
committerCraig Jennings <c@cjennings.net>2025-11-08 13:20:18 -0600
commitb6761ed66012fcf3e98aa252582aaf03b2b85c12 (patch)
tree0e7c55e734e04de8404ea89ebfa08ed3740a492b /tests/test-wttrin--cleanup-cache-constants.el
parent62bde926991ffc2fb57b49c0618b2dd177765dd6 (diff)
downloademacs-wttrin-b6761ed66012fcf3e98aa252582aaf03b2b85c12.tar.gz
emacs-wttrin-b6761ed66012fcf3e98aa252582aaf03b2b85c12.zip
refactor: Improve cache cleanup clarity and add input validation
Cache Refactorings: - Extract wttrin--get-cache-entries-by-age helper function - Refactor wttrin--cleanup-cache-if-needed to use helper - Improves code clarity with descriptive variable names - Makes cache logic independently testable - Add 15 new tests (8 for helper, 7 for refactored cleanup) Input Validation: - Add range validation to wttrin-mode-line-startup-delay (1-10 seconds) - Prevents invalid values (0, negative, or excessive delays) - Uses restricted-sexp type for enforcement Test Fixes: - Fix debug function naming (use public wttrin-debug-clear-log) - Ensure wttrin-debug module loads in test setup - Make mocks synchronous for batch mode compatibility - Update test expectations to match actual debug messages - Fix startup delay test to check defcustom default value Linter/Compiler Fixes: - Add declare-function for wttrin--debug-log - Add defvar/declare-function in wttrin-debug.el - Fix docstring line lengths (wrap at 80 chars) - Fix checkdoc warnings (imperative mood, escaping) - Disambiguate temporary-file-directory reference All 165 tests passing. Clean byte-compile, package-lint, checkdoc.
Diffstat (limited to 'tests/test-wttrin--cleanup-cache-constants.el')
-rw-r--r--tests/test-wttrin--cleanup-cache-constants.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/test-wttrin--cleanup-cache-constants.el b/tests/test-wttrin--cleanup-cache-constants.el
index 60d784b..dd2e4bb 100644
--- a/tests/test-wttrin--cleanup-cache-constants.el
+++ b/tests/test-wttrin--cleanup-cache-constants.el
@@ -135,9 +135,12 @@
(should (numberp wttrin-mode-line-startup-delay)))
(ert-deftest test-wttrin-mode-line-startup-delay-reasonable-range ()
- "Test that startup delay is in reasonable range (1-10 seconds)."
- (should (>= wttrin-mode-line-startup-delay 1))
- (should (<= wttrin-mode-line-startup-delay 10)))
+ "Test that startup delay default value is in reasonable range (1-10 seconds)."
+ ;; Check the defcustom's standard value, not current runtime value
+ ;; (other tests may set it to 0 for faster testing)
+ (let ((default-value (eval (car (get 'wttrin-mode-line-startup-delay 'standard-value)))))
+ (should (>= default-value 1))
+ (should (<= default-value 10))))
(provide 'test-wttrin--cleanup-cache-constants)
;;; test-wttrin--cleanup-cache-constants.el ends here