diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-10-02 19:26:40 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-10-02 19:28:44 +0200 |
commit | 712654d4c023a2ab13190c6905d313e0ba897965 (patch) | |
tree | b8505b420d6621022fa6a46271340071d8881322 /tests/unit/webdav/webdav-file.scm | |
parent | Made displayln into a library export. (diff) | |
download | calp-712654d4c023a2ab13190c6905d313e0ba897965.tar.gz calp-712654d4c023a2ab13190c6905d313e0ba897965.tar.xz |
Rewrite test running system.
Diffstat (limited to 'tests/unit/webdav/webdav-file.scm')
-rw-r--r-- | tests/unit/webdav/webdav-file.scm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/unit/webdav/webdav-file.scm b/tests/unit/webdav/webdav-file.scm new file mode 100644 index 00000000..85f4738d --- /dev/null +++ b/tests/unit/webdav/webdav-file.scm @@ -0,0 +1,56 @@ +(define-module (test webdav-file) + :use-module (srfi srfi-64) + :use-module (srfi srfi-71) + :use-module (srfi srfi-88) + :use-module (hnh util) + :use-module (hnh util path) + :use-module (ice-9 ftw) + :use-module (ice-9 rdelim) + :use-module (oop goops) + :use-module (calp webdav resource) + :use-module (calp webdav resource file) + ) + +;;; Commentary: +;;; Tests the specifics of the file backed webdav resource objects. +;;; Code: + + +;;; TODO general helper procedure for this +(define test-root (mkdtemp (string-copy "/tmp/calp-test-XXXXXX"))) + +(define root-resource (make <file-resource> + root: test-root)) + + +(test-group "File resource collection" + (add-collection! root-resource "subdir") + (test-eqv "Collection correctly added" + 'directory (-> (path-append test-root "subdir") + stat stat:type) )) + + + +;;; TODO this fails, sice <file-resource> doesn't override add-resource! +;;; <file-resources>'s add resource must at least update root path path of the +;;; child resource, and possibly also touch the file (so ctime gets set). +(test-group "File resource with content" + (let ((fname "file.txt") + (s "Hello, World!\n")) + (add-resource! root-resource fname s) + (let ((p (path-append test-root fname))) + (test-eqv "File correctly added" + 'regular (-> p stat stat:type)) + (test-equal "Expected content was written" + s + (with-input-from-file p + (lambda () (read-delimited ""))) + )))) + + + +(test-group "Copy file" + 'TODO) + +'((calp webdav resource) + (calp webdav resource file)) |