diff options
Diffstat (limited to 'tests/ldp-primer.scm')
-rw-r--r-- | tests/ldp-primer.scm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/ldp-primer.scm b/tests/ldp-primer.scm new file mode 100644 index 0000000..6f3d5c5 --- /dev/null +++ b/tests/ldp-primer.scm @@ -0,0 +1,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") |