aboutsummaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 13:32:22 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 13:32:22 -0400
commit11049db5700067652469e3408c5f4d8faf8bb332 (patch)
tree8ecb3692d01e3096da1802becd55acdffef8135b /tests/test-calendar-sync.el
parent4e48432c5020d545c57e3ff24c43bc291acb7250 (diff)
downloaddotemacs-11049db5700067652469e3408c5f4d8faf8bb332.tar.gz
dotemacs-11049db5700067652469e3408c5f4d8faf8bb332.zip
fix(calendar-sync): atomic writes, curl --fail, and zero-event vs garbage
Three robustness fixes from the config audit. (1) calendar-sync--write-file and --save-state now write a temp file in the same directory and rename it into place, so org-agenda or chime reading mid-write never sees a half-written calendar. (2) The two curl fetches gain --fail, so an HTTP 404/500 error page exits non-zero instead of flowing its HTML into conversion. (3) calendar-sync--parse-ics distinguishes a healthy zero-event calendar (a real iCalendar with BEGIN:VCALENDAR and no in-window events returns the header) from garbage (no VCALENDAR returns nil), so a near-empty calendar no longer reports "parse failed". New robustness tests; the empty-calendar boundary test updated to the corrected behavior. Verified against the live feed: all three calendars fetch and write cleanly.
Diffstat (limited to 'tests/test-calendar-sync.el')
-rw-r--r--tests/test-calendar-sync.el9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/test-calendar-sync.el b/tests/test-calendar-sync.el
index 62b00aba1..f562cfc61 100644
--- a/tests/test-calendar-sync.el
+++ b/tests/test-calendar-sync.el
@@ -471,11 +471,14 @@ Earlier events should appear first in the output."
(should (string-match-p "\\* Event 1" org-content))
(should (string-match-p "\\* Event 2" org-content))))
-(ert-deftest test-calendar-sync--parse-ics-boundary-empty-calendar-returns-nil ()
- "Test parsing empty calendar (no events)."
+(ert-deftest test-calendar-sync--parse-ics-boundary-empty-calendar-returns-header ()
+ "A valid but empty iCalendar (no events) is a healthy zero-event calendar:
+it returns a non-nil header so the sync reports success, not a parse failure.
+Garbage with no BEGIN:VCALENDAR still returns nil (covered elsewhere)."
(let* ((ics "BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR")
(org-content (calendar-sync--parse-ics ics)))
- (should (null org-content))))
+ (should org-content)
+ (should (string-match-p "Calendar Events" org-content))))
(ert-deftest test-calendar-sync--parse-ics-error-malformed-ics-returns-nil ()
"Test that malformed .ics returns nil and sets error."