<feed xmlns='http://www.w3.org/2005/Atom'>
<title>emacs-wttrin/tests/test-wttrin--cleanup-cache-constants.el, branch main</title>
<subtitle>Emacs frontend for Igor Chubin's wttr.in weather service
</subtitle>
<id>https://git.cjennings.net/emacs-wttrin/atom?h=main</id>
<link rel='self' href='https://git.cjennings.net/emacs-wttrin/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/'/>
<updated>2026-02-18T01:14:14+00:00</updated>
<entry>
<title>refactor: tests: standardize naming, consolidate files, and expand testutil</title>
<updated>2026-02-18T01:14:14+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-02-18T01:14:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/commit/?id=28b7e4cecadce207d532b8d42346c3823450a35f'/>
<id>urn:sha1:28b7e4cecadce207d532b8d42346c3823450a35f</id>
<content type='text'>
- 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-&lt;module&gt;-&lt;category&gt;-&lt;scenario&gt;-&lt;expected-result&gt; 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 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>refactor: Improve cache cleanup clarity and add input validation</title>
<updated>2025-11-08T19:20:18+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2025-11-08T19:16:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/commit/?id=b6761ed66012fcf3e98aa252582aaf03b2b85c12'/>
<id>urn:sha1:b6761ed66012fcf3e98aa252582aaf03b2b85c12</id>
<content type='text'>
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.
</content>
</entry>
<entry>
<title>refactor: config: replace magic numbers with named constants</title>
<updated>2025-11-08T17:33:31+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2025-11-08T17:33:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/emacs-wttrin/commit/?id=19e88c1ed7ecde966372adefeb3d468374ef1dd7'/>
<id>urn:sha1:19e88c1ed7ecde966372adefeb3d468374ef1dd7</id>
<content type='text'>
Replace two magic numbers with self-documenting constants:

1. Cache cleanup percentage (line 395):
   - Before: (dotimes (_ (/ (length entries) 5))
   - After: (dotimes (_ (floor (* (length entries) wttrin--cache-cleanup-percentage)))
   - Added: wttrin--cache-cleanup-percentage constant (0.20 = 20%)
   - Explains WHY 20%: provides buffer before next cleanup cycle

2. Mode-line startup delay (line 508):
   - Before: (run-at-time 3 nil #'wttrin--mode-line-fetch-weather)
   - After: (run-at-time wttrin-mode-line-startup-delay nil ...)
   - Added: wttrin-mode-line-startup-delay defcustom (default 3 seconds)
   - Now user-customizable, range 1-5 seconds recommended

Added comprehensive tests (8 tests, all passing):
- 5 tests verify cache cleanup behavior (removes ~20% of oldest entries)
- 3 tests verify startup delay defcustom exists and has reasonable value

Benefits:
- Self-documenting code (explains WHY these values exist)
- Startup delay is now user-customizable
- Easier for future maintainers to understand rationale

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
