summaryrefslogtreecommitdiff
path: root/tests/atom.scm
blob: c6cd26816eaddd280e4944405f46400153a4a259 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(define-module (tests atom)
  #:use-module (src dates)
  #:use-module (srfi srfi-64)
  #:use-module ((src atom) #:prefix atom:))

(test-begin "Atom feed")

(define me (atom:person "Ekaitz"
                         #:email "ekaitz@elenq.tech"
                         #:uri   "https://elenq.tech"))

(define feed
  (atom:feed #:title "Mi feed"
              #:subtitle  "Este es mi feed"
              #:uri       "https://feed.elenq.tech"
              #:posts     (list
                            (atom:entry #:title "first entry"
                                        #:published (string/ISO->date "2023-03-01")
                                        #:authors (list me)
                                        #:summary-html '(p "Este es el resumen")
                                        #:content-html '(p "Este es el contenido")
                                        #:categories (list "una" "dos" "tres")
                                        #:media (list)))))
  ;; TODO: Test media (reads file)

(let ((atom-feed (with-output-to-string (lambda () (atom:render feed)))))
  (test-assert (string=? (pk atom-feed)
                         "<?xml version=\"1.0\" encoding=\"utf-8\"?><feed xmlns=\"http://www.w3.org/2005/Atom\"><id>https://feed.elenq.tech</id><title>Mi feed</title><link href=\"https://feed.elenq.tech\" rel=\"self\" /><updated>2023-03-01T00:00:00+0100</updated><subtitle>Este es mi feed</subtitle><entry><id>https://feed.elenq.tech/first-entry</id><title>first entry</title><published>2023-03-01T00:00:00+0100</published><updated>2023-03-01T00:00:00+0100</updated><author><name>Ekaitz</name><uri>https://elenq.tech</uri><email>ekaitz@elenq.tech</email></author><summary type=\"html\"><p>Este es el resumen</p></summary><content type=\"html\"><p>Este es el contenido</p></content><category term=\"una\" /><category term=\"dos\" /><category term=\"tres\" /></entry></feed>")))

(test-end "Atom feed")