summaryrefslogtreecommitdiff
path: root/tests/ldp-primer.scm
blob: 6f3d5c5efd2367ffe24297abab12638260914b0d (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
55
(define-module (ldp-primer)
  #:use-module (srfi srfi-64)
  #:use-module (web request)
  #:use-module (web response)
  #:use-module (web uri)
  #:use-module (ldp)
  #:use-module (ldp precondition)
  #:use-module (ldp resource update))

(system* "rm" "-rf" "primer")

(catch #t
  (lambda ()
    (mkdir "primer"))
  (lambda err #t))
(chdir "primer")

(test-begin "setup")
(let ((request
       (call-with-input-string "POST / HTTP/1.1\r\n\
Host: example.org\r\n\
Content-Type: text/turtle\r\n\
Link: <http://www.w3.org/ns/ldp/BasicContainer>; rel=\"type\"\r\n\
Slug: alice\r\n\r\n"
	 read-request))
      (request-body "@prefix dcterms: <http://purl.org/dc/terms/>.
@prefix ldp: <http://www.w3.org/ns/ldp#>.

<http://example.org/alice/> a ldp:Container, ldp:BasicContainer;
  dcterms:title 'Alice’s data storage on the Web' ."))
  (call-with-values (lambda () (respond request request-body))
    (lambda (response response-body)
      (test-equal "Slug is respected on empty container"
	(string->uri-reference "/alice")
	(response-location response)))))
(test-end "setup")

(test-begin "cleanup")
(let ((request
       (call-with-input-string "DELETE /alice HTTP/1.1\r\n\
Host: example.org\r\n\r\n"
	 read-request))
      (request-body #f))
  (call-with-values (lambda () (respond request request-body))
    (lambda (response response-body)
      (test-eq "Cleaning OK"
	200
	(response-code response)))))
(test-end "cleanup")

(delete-file "representation/manifest.xml")
(delete-file "representation/content")
(rmdir "representation")
(chdir "..")
(rmdir "primer")