summaryrefslogtreecommitdiff
path: root/tests/server-content.scm
blob: c546dea40b245922ee3c5e5439f3e6d6c9b51059 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(use-modules (webid-oidc server resource content)
             (webid-oidc fetch)
             (webid-oidc testing)
             (webid-oidc errors)
             (web uri)
             (web response)
             (rnrs bytevectors)
             (ice-9 optargs)
             (ice-9 receive)
             (oop goops))

(with-test-environment
 "server-content"
 (lambda ()
   (false-if-exception
    ;; This is the etag of the root with the seed of the test
    (delete-file "tests/server-content.home/webid-oidc/server/content/6/8OMG_V5x-KmI6TI"))
   (false-if-exception
    ;; This is the etag of /wtf
    (delete-file "tests/server-content.home/webid-oidc/server/content/X/hqM_2Avn5_egTzs"))
   (receive (/ /wtf)
       (with-session
        (lambda (content-type contained static-content create delete)
          (let ((/ (create 'text/turtle '("/whatever" "/you" "/want")
                           "# This is the content of the root"))
                (/wtf (create 'text/plain '() "This is the content of the wtf")))
            (unless (equal? (static-content /wtf)
                            (string->utf8 "This is the content of the wtf"))
              (exit 1))
            (delete /wtf)
            (unless (eq? (content-type /wtf) 'text/plain)
              ;; It has survived in the cache
              (exit 2))
            (values / /wtf))))
     (with-session
      (lambda (content-type contained static-content create delete)
        (unless
            (with-exception-handler
                (lambda (error)
                  ;; Good, we can’t load /wtf
                  #t)
              (lambda ()
                (content-type /wtf)
                #f)
              #:unwind? #t)
          ;;We could read /wtf, it has not been deleted
          (exit 3))
        (unless (eq? (content-type /) 'text/turtle)
          (exit 4))
        (unless (equal? (contained /) '("/whatever" "/you" "/want"))
          (exit 5))
        (unless (equal? (static-content /)
                        (string->utf8 "# This is the content of the root"))
          (exit 6)))))))