aboutsummaryrefslogtreecommitdiff
path: root/tests/recurring.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-12-30 02:11:38 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-12-30 02:11:38 +0100
commitb6d12e309b207c25de7873f658aa0f88ea77080c (patch)
treeea4a8515c4c5b3e6798f6b3b69e24ad76f53b883 /tests/recurring.scm
parentFix keyword argument. (diff)
downloadcalp-b6d12e309b207c25de7873f658aa0f88ea77080c.tar.gz
calp-b6d12e309b207c25de7873f658aa0f88ea77080c.tar.xz
Reworked tests.
Diffstat (limited to 'tests/recurring.scm')
-rw-r--r--tests/recurring.scm76
1 files changed, 35 insertions, 41 deletions
diff --git a/tests/recurring.scm b/tests/recurring.scm
index 331343c6..ce5a12fd 100644
--- a/tests/recurring.scm
+++ b/tests/recurring.scm
@@ -1,47 +1,41 @@
-(use-modules (srfi srfi-1)
- (srfi srfi-19)
- (srfi srfi-19 util)
- (srfi srfi-41)
-
- (util)
- (vcomponent)
- (vcomponent output)
- (vcomponent recurrence))
-
-(define (display-timespan ev)
- (format #t "~a -- ~a~%"
- (time->string (attr ev "DTSTART"))
- (time->string (attr ev "DTEND"))))
-
-(define (tcal str)
- (format #f "~a/recurrence/~a"
- (getenv "TESTPATH")
- str))
-
-(define cal-1 (make-vcomponent (tcal "simple-daily.ics")))
-
-(let ((ev (car (children cal-1 'VEVENT))))
- (format #t "~a~%" (attr ev 'RRULE))
+(((srfi srfi-41) stream-take stream-map)
+ ((srfi srfi-1) find)
+ ((guile) make-struct/no-tail)
+ ((vcomponent base) children extract type)
+ ((vcomponent) parse-calendar)
+ ((vcomponent recurrence) generate-recurrence-set))
+
+(define cal-1
+ (call-with-input-string
+ "BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-Manual baby!
+BEGIN:VEVENT
+SUMMARY:Repeating event
+DTSTART;20190302T160000
+DTEND;VALUE=DATE-TIME:20190302T170000
+DTSTAMP;VALUE=DATE-TIME:20190302T165849Z
+UID:USG7HSRFJSZ6YURWCNSH3UCKI2PHP19SWGBG
+SEQUENCE:0
+RRULE:FREQ=DAILY
+END:VEVENT
+END:VCALENDAR"
+ parse-calendar))
+
+(let ((ev (find (lambda (e) (eq? 'VEVENT (type e))) (children cal-1))))
+ (test-assert "Generate Recurrence set" (generate-recurrence-set ev))
(test-equal "Generate First"
- (map (extract 'DTSTART)
- (stream->list (stream-take 5 (generate-recurrence-set ev))))
- (let* ((s0 (attr ev 'DTSTART))
- (s1 (add-day s0))
- (s2 (add-day s1))
- (s3 (add-day s2))
- (s4 (add-day s3)))
- (list s0 s1 s2 s3 s4)))
+ (stream-take 5 (stream-map (extract 'DTSTART)
+ (generate-recurrence-set ev)))
+ (stream-take 5 (day-stream (attr ev 'DTSTART))))
;; We run the exact same thing a secound time, since I had an error with
;; that during development.
- (test-equal "Generate Again"
- (map (extract 'DTSTART)
- (stream->list (stream-take 5 (generate-recurrence-set ev))))
- (let* ((s0 (attr ev 'DTSTART))
- (s1 (add-day s0))
- (s2 (add-day s1))
- (s3 (add-day s2))
- (s4 (add-day s3)))
- (list s0 s1 s2 s3 s4))) )
+
+ ;; (test-equal "Generate Again"
+ ;; (stream-take 5 (stream-map (extract 'DTSTART)
+ ;; (generate-recurrence-set ev)))
+ ;; (stream-take 5 (day-stream (attr ev 'DTSTART))))
+ )