blob: cc27e4b9d9e67b081c89c57af8578965431f9906 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
(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)
#:use-module (rnrs bytevectors))
(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 "example1-2")
(let ((request
(call-with-input-string "GET /alice/ HTTP/1.1\r\n\
Host: example.org\r\n\
Accept: text/turtle\r\n\r\n"
read-request))
(request-body #f))
(call-with-values (lambda () (respond request request-body))
(lambda (response response-body)
(test-eq "Example 2: OK"
200
(response-code response))
(test-eq "Example 2: content-type"
'text/turtle
(car (response-content-type response)))
(test-equal "Example 2: links"
"<http://www.w3.org/ns/ldp#BasicContainer>; rel=\"type\", <http://www.w3.org/ns/ldp#Resource>; rel=\"type\""
(assoc-ref (response-headers response) 'link))
(test-equal "Example 2: allow"
'(HEAD GET POST PUT DELETE OPTIONS)
(response-allow response))
(test-eq "Example 2: has ETag"
#t
(not (not (response-etag response))))
(test-eq "Example 2: ETag is strong"
#t
(cdr (response-etag response)))
(test-equal "Example 2: content"
"@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' .
</alice> a <http://www.w3.org/ns/ldp#Container>,
<http://www.w3.org/ns/ldp#BasicContainer> .
"
(utf8->string response-body)))))
(test-end "example1-2")
(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")
|