aboutsummaryrefslogtreecommitdiff
path: root/tests/test-host-environment--detect-system-timezone.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-19 09:56:20 -0400
committerCraig Jennings <c@cjennings.net>2026-06-19 09:56:20 -0400
commitac552d5cc534cda5f3726c5848ed0162ca4cfd53 (patch)
treef3000205fd24b6f2470befd0d1d3a1d22d70a60b /tests/test-host-environment--detect-system-timezone.el
parent10c0d574889f177b669a4f4e55a51076da991e7c (diff)
downloaddotemacs-ac552d5cc534cda5f3726c5848ed0162ca4cfd53.tar.gz
dotemacs-ac552d5cc534cda5f3726c5848ed0162ca4cfd53.zip
test: cover pure-logic gaps found by the coverage audit
I ran make coverage and worked the report function by function, separating real gaps from interactive/IO wrappers that aren't unit-test targets. These tests fill the genuine pure-logic holes: predicates, parsers, formatters, transforms, and three modules that had no test file at all. New files cover car-member (local-repository), show-kill-insert-item (show-kill-ring), the oauth2-auto plstore cache fix (auth-config), the coverage-core project-root fallback, reconcile--dirty-p, and the recurrence-frequency dispatch in calendar-sync. Extended files add the missing branches: coverage-core's merge-base and diff /dev/null handling plus the staged and branch-vs-main scopes, the detect-system-timezone symlink path, user-constants no-op and optional-failure branches, the elfeed playlist branch with HTML-entity decoding, the duplicate-line no-comment-syntax guard, and several calendar-sync edges (exception field overrides, timestamp seconds and TZID fallback, property-line position advancement, parse-ics nil and out-of-range inputs). Mocks sit at the real boundaries (plstore, url-retrieve, process-file, git) so each function's own logic runs. Dates come from relative helpers. About 65 tests added across 15 files, and the full suite stays green.
Diffstat (limited to 'tests/test-host-environment--detect-system-timezone.el')
-rw-r--r--tests/test-host-environment--detect-system-timezone.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-host-environment--detect-system-timezone.el b/tests/test-host-environment--detect-system-timezone.el
index c24ac183a..1b5e61081 100644
--- a/tests/test-host-environment--detect-system-timezone.el
+++ b/tests/test-host-environment--detect-system-timezone.el
@@ -74,5 +74,30 @@ contents primitives."
((symbol-function 'file-symlink-p) (lambda (_) nil)))
(should-not (cj/detect-system-timezone))))
+(ert-deftest test-host-environment-detect-tz-symlink-target-extracts-zone ()
+ "Boundary: with methods 1-3 nil, a /etc/localtime symlink into zoneinfo
+yields the zone after the /zoneinfo/ segment."
+ (cl-letf (((symbol-function 'cj/match-localtime-to-zoneinfo)
+ (lambda () nil))
+ ((symbol-function 'getenv) (lambda (_) nil))
+ ((symbol-function 'file-exists-p) (lambda (_) nil))
+ ((symbol-function 'file-symlink-p)
+ (lambda (path) (string= path "/etc/localtime")))
+ ((symbol-function 'file-truename)
+ (lambda (_) "/usr/share/zoneinfo/America/Denver")))
+ (should (equal (cj/detect-system-timezone) "America/Denver"))))
+
+(ert-deftest test-host-environment-detect-tz-symlink-without-zoneinfo-is-nil ()
+ "Error: a symlink target with no /zoneinfo/ segment yields nil."
+ (cl-letf (((symbol-function 'cj/match-localtime-to-zoneinfo)
+ (lambda () nil))
+ ((symbol-function 'getenv) (lambda (_) nil))
+ ((symbol-function 'file-exists-p) (lambda (_) nil))
+ ((symbol-function 'file-symlink-p)
+ (lambda (path) (string= path "/etc/localtime")))
+ ((symbol-function 'file-truename)
+ (lambda (_) "/var/lib/elsewhere/localtime")))
+ (should-not (cj/detect-system-timezone))))
+
(provide 'test-host-environment--detect-system-timezone)
;;; test-host-environment--detect-system-timezone.el ends here