summaryrefslogtreecommitdiff
path: root/tests/post.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-01-26 08:08:34 -0500
committerDavid Thompson <dthompson2@worcester.edu>2022-01-26 08:09:36 -0500
commit77dd14980881d9b659e23643eab5fe2ce75efe6a (patch)
treeb77293d4c90f15b467196da80adc6256803ccf7b /tests/post.scm
parent33d1833652d79f2df0f9a469e1e88d579603f022 (diff)
Fix test suite.v0.2.6
Diffstat (limited to 'tests/post.scm')
-rw-r--r--tests/post.scm88
1 files changed, 42 insertions, 46 deletions
diff --git a/tests/post.scm b/tests/post.scm
index b0407c9..db1a82c 100644
--- a/tests/post.scm
+++ b/tests/post.scm
@@ -1,5 +1,5 @@
;;; Haunt --- Static site generator for GNU Guile
-;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2015, 2022 David Thompson <davet@gnu.org>
;;;
;;; This file is part of Haunt.
;;;
@@ -17,11 +17,10 @@
;;; along with Haunt. If not, see <http://www.gnu.org/licenses/>.
(define-module (test-post)
+ #:use-module (haunt post)
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-64)
- #:use-module (haunt post))
-
-(test-begin "post")
+ #:use-module (tests helper))
(define (make-date* year month day)
(make-date 0 0 0 0 day month year 0))
@@ -29,57 +28,54 @@
(define %tzoffset
(date-zone-offset (string->date "2015-09-05" "~Y~m~d")))
-(test-equal "post-ref"
- '(hello test)
- (post-ref (make-post "foo.skr" '((tags hello test)) '()) 'tags))
+(with-tests "post"
+ (test-equal "post-ref"
+ '(hello test)
+ (post-ref (make-post "foo.skr" '((tags hello test)) '()) 'tags))
-(test-equal "post-slug"
- "hello-world"
- (post-slug (make-post "foo.skr" '((title . "Hello, world!")) '())))
+ (test-equal "post-slug"
+ "hello-world"
+ (post-slug (make-post "foo.skr" '((title . "Hello, world!")) '())))
-(test-equal "post-date, no date metadata"
- %default-date
- (post-date (make-post "foo.skr" '() '())))
+ (test-equal "post-date, no date metadata"
+ %default-date
+ (post-date (make-post "foo.skr" '() '())))
-(let ((date (make-date* 2015 10 15)))
- (test-equal "post-date, date metadata"
- date
- (post-date (make-post "foo.skr" `((date . ,date)) '()))))
+ (let ((date (make-date* 2015 10 15)))
+ (test-equal "post-date, date metadata"
+ date
+ (post-date (make-post "foo.skr" `((date . ,date)) '()))))
-(let ((oldest (make-post "foo.skr" `((date . ,(make-date* 2015 10 13))) '()))
- (newest (make-post "bar.skr" `((date . ,(make-date* 2015 10 15))) '()))
- (middle (make-post "baz.skr" `((date . ,(make-date* 2015 10 14))) '())))
- (test-equal "posts/reverse-chronological"
- (list newest middle oldest)
- (posts/reverse-chronological (list oldest newest middle))))
+ (let ((oldest (make-post "foo.skr" `((date . ,(make-date* 2015 10 13))) '()))
+ (newest (make-post "bar.skr" `((date . ,(make-date* 2015 10 15))) '()))
+ (middle (make-post "baz.skr" `((date . ,(make-date* 2015 10 14))) '())))
+ (test-equal "posts/reverse-chronological"
+ (list newest middle oldest)
+ (posts/reverse-chronological (list oldest newest middle))))
-(let ((foo-post (make-post "foo.skr" '((tags "foo")) '()))
- (another-foo-post (make-post "another-foo.skr" '((tags "foo")) '()))
- (bar-post (make-post "bar.skr" '((tags "bar")) '())))
- (test-equal "posts/group-by-tag"
- `(("foo" ,foo-post ,another-foo-post) ("bar" ,bar-post))
- (posts/group-by-tag (list another-foo-post foo-post bar-post))))
+ (let ((foo-post (make-post "foo.skr" '((tags "foo")) '()))
+ (another-foo-post (make-post "another-foo.skr" '((tags "foo")) '()))
+ (bar-post (make-post "bar.skr" '((tags "bar")) '())))
+ (test-equal "posts/group-by-tag"
+ `(("foo" ,foo-post ,another-foo-post) ("bar" ,bar-post))
+ (posts/group-by-tag (list another-foo-post foo-post bar-post))))
-(test-equal "parse-metadata, tags"
- '("foo" "bar" "baz")
- (parse-metadata 'tags "foo, bar, baz"))
+ (test-equal "parse-metadata, tags"
+ '("foo" "bar" "baz")
+ (parse-metadata 'tags "foo, bar, baz"))
-(test-equal "parse-metadata, date"
- (make-date 0 0 30 22 15 10 2015 %tzoffset)
- (parse-metadata 'date "2015-10-15 22:30"))
+ (test-equal "parse-metadata, date"
+ (make-date 0 0 30 22 15 10 2015 %tzoffset)
+ (parse-metadata 'date "2015-10-15 22:30"))
-(test-equal "read-metadata-headers"
- `((tags "foo" "bar" "baz")
- (date . ,(make-date 0 0 30 22 15 10 2015 %tzoffset))
- (title . "Hello, World!"))
- (pk 'meta (call-with-input-string "title: Hello, World!
+ (test-equal "read-metadata-headers"
+ `((tags "foo" "bar" "baz")
+ (date . ,(make-date 0 0 30 22 15 10 2015 %tzoffset))
+ (title . "Hello, World!"))
+ (call-with-input-string "title: Hello, World!
date: 2015-10-15 22:30
tags: foo, bar, baz
---
"
- read-metadata-headers)))
-
-(test-end)
-
-
-(exit (zero? (test-runner-fail-count (test-runner-current))))
+ read-metadata-headers))
+ )