aboutsummaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--date-to-time.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-03 07:53:51 -0500
committerCraig Jennings <c@cjennings.net>2026-05-03 07:53:51 -0500
commit8ec668d6749b22f47a4c614d0965445dcfa86f50 (patch)
tree35195dad12fd3680dc129b223a1668b95570a285 /tests/test-calendar-sync--date-to-time.el
parent6936f5b60b61dcf41cbda75813d7f259733eedf2 (diff)
downloaddotemacs-8ec668d6749b22f47a4c614d0965445dcfa86f50.tar.gz
dotemacs-8ec668d6749b22f47a4c614d0965445dcfa86f50.zip
test(calendar-sync): fix weekday-string lookup to match production
The boundary test for `calendar-sync--expand-weekly` with a 5-element UNTIL built its byday string from `'("SU" "MO" "TU" "WE" "TH" "FR" "SA")`, a 0-indexed Sunday-first array. The production code uses Monday=1, Sunday=7 throughout: `calendar-sync--date-weekday` returns it that way and `calendar-sync--weekday-to-number` expects it. When start-date landed on a Sunday (start-weekday=7), `(nth 7 array)` overran the 7-element list and returned nil. Then byday=(nil), and inside expand-weekly `(mod (- nil current-weekday) 7)` raised "wrong-type-argument number-or-marker-p nil". The mismatch made the test fail every Saturday (when "tomorrow" is Sunday) and pass the other six days. The flake had been blamed on stale `.elc` in earlier triage, but `make clean && make test` reproduced the failure on Saturdays. I switched the lookup to `(nth (1- start-weekday) '("MO" "TU" "WE" "TH" "FR" "SA" "SU"))`, the same convention as every other weekday-mapping in the codebase. I verified across all 7 weekdays via a faked `current-time`: each produces exactly 1 occurrence as expected. Production code is internally consistent. No production change needed.
Diffstat (limited to 'tests/test-calendar-sync--date-to-time.el')
-rw-r--r--tests/test-calendar-sync--date-to-time.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/test-calendar-sync--date-to-time.el b/tests/test-calendar-sync--date-to-time.el
index 931d5929..b877eb06 100644
--- a/tests/test-calendar-sync--date-to-time.el
+++ b/tests/test-calendar-sync--date-to-time.el
@@ -104,7 +104,14 @@ Mirrors the real DeepSat Mgmt Sync case: RRULE with UNTIL ~6 days after start."
(until-5 (append (test-calendar-sync-time-date-only 7) '(19 59)))
(start-weekday (calendar-sync--date-weekday
(list (nth 0 start-date) (nth 1 start-date) (nth 2 start-date))))
- (weekday-str (nth start-weekday '("SU" "MO" "TU" "WE" "TH" "FR" "SA")))
+ ;; calendar-sync--date-weekday returns 1..7 with Monday=1, Sunday=7
+ ;; (matching calendar-sync--weekday-to-number), so the lookup array
+ ;; runs Mon..Sun and we index with (1- start-weekday). The earlier
+ ;; "SU MO TU WE TH FR SA" array misread the convention as 0-indexed
+ ;; Sunday-first, which silently returned nil for start-weekday=7
+ ;; (Sunday) and crashed inside expand-weekly every Saturday.
+ (weekday-str (nth (1- start-weekday)
+ '("MO" "TU" "WE" "TH" "FR" "SA" "SU")))
(base-event (list :summary "Short-Lived Series"
:start start-date
:end end-date))