aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-17 19:03:37 -0500
committerCraig Jennings <c@cjennings.net>2026-07-17 19:03:37 -0500
commit65b23131a2014032ffc13a404025188d9fc9aabe (patch)
tree22ba81c44597e09aa4e0c6cf15c1fcc7b90439e0
parentf30a96edd320337ea9a35d2f0fc0cf21f94deb05 (diff)
downloaddotemacs-65b23131a2014032ffc13a404025188d9fc9aabe.tar.gz
dotemacs-65b23131a2014032ffc13a404025188d9fc9aabe.zip
test: assert recurring-events window against calendar-sync's own range
The rolling-window integration test hand-rolled its bound as now minus 90 days to now plus 365 days at the current clock time. The code's window is minus-3 / plus-12 calendar months at day granularity. So a boundary occurrence stamped at midnight sat inside the code's window but before the now-minus-90-days bound, and the test passed or failed by the day it ran (green 2026-07-16, red 2026-07-17). I switched the assertion to calendar-sync--get-date-range, so the test checks the invariant it names: every emitted occurrence lands within the window the pipeline computed, stable on any date.
-rw-r--r--tests/test-integration-recurring-events.el21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/test-integration-recurring-events.el b/tests/test-integration-recurring-events.el
index 4e778547..8339d167 100644
--- a/tests/test-integration-recurring-events.el
+++ b/tests/test-integration-recurring-events.el
@@ -222,12 +222,19 @@ Validates:
(test-integration-recurring-events-setup)
(unwind-protect
(let* ((org-output (calendar-sync--parse-ics test-integration-recurring-events--weekly-ics))
- (now (current-time))
- (three-months-ago (time-subtract now (* 90 24 3600)))
- (twelve-months-future (time-add now (* 365 24 3600))))
+ (range (calendar-sync--get-date-range))
+ (window-start (nth 0 range))
+ (window-end (nth 1 range)))
(should (stringp org-output))
- ;; Parse all dates from output
+ ;; Every emitted occurrence must fall within the pipeline's own window
+ ;; (-3/+12 calendar months at day granularity, from
+ ;; `calendar-sync--get-date-range'). Asserting against that boundary,
+ ;; rather than a hand-rolled now +/- fixed-day approximation, keeps the
+ ;; test robust on every date: a valid boundary occurrence stamped at
+ ;; midnight used to read as out-of-range against a now-90d bound taken
+ ;; at the current clock time, so the test failed or passed depending on
+ ;; the day it ran.
(with-temp-buffer
(insert org-output)
(goto-char (point-min))
@@ -237,9 +244,9 @@ Validates:
(month (string-to-number (match-string 2)))
(day (string-to-number (match-string 3)))
(event-time (encode-time 0 0 0 day month year)))
- ;; All dates should be within window
- (when (or (time-less-p event-time three-months-ago)
- (time-less-p twelve-months-future event-time))
+ ;; Within [window-start, window-end] inclusive.
+ (when (or (time-less-p event-time window-start)
+ (time-less-p window-end event-time))
(setq all-dates-in-range nil))))
(should all-dates-in-range))))
(test-integration-recurring-events-teardown)))