diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 15:31:00 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 20:29:14 +0100 |
commit | f7716ac1a87649cad96242f2d5bf0a987d7f430c (patch) | |
tree | b4b84951ef468fd644c42e9e0fee535d879f0387 /tests/test/server.scm | |
parent | Cleanup in (hnh util path). (diff) | |
download | calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.gz calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.xz |
Add new tests.
Diffstat (limited to 'tests/test/server.scm')
-rw-r--r-- | tests/test/server.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test/server.scm b/tests/test/server.scm new file mode 100644 index 00000000..1b5d4775 --- /dev/null +++ b/tests/test/server.scm @@ -0,0 +1,24 @@ +;;; Commentary: +;; Tests parse-endpoint-string, used for defining server routes. +;;; Code: + +(define-module (test server) + :use-module (srfi srfi-64) + :use-module (srfi srfi-88) + :use-module ((web http make-routes) + :select (parse-endpoint-string)) + :use-module ((hnh util) :select (let*))) + +(test-assert "Check that parsing doesn't crash" + (parse-endpoint-string "/static/:dir/:file")) + +;; Checks that parsing produces correct results +(let* ((path args (parse-endpoint-string "/static/:dir/:file"))) + (test-equal "/static/([^/.]+)/([^/.]+)" path) + (test-equal '(dir file) args)) + +;; Checks that parsing with custom regex works +;; along with literal periods. +(let* ((path args (parse-endpoint-string "/static/:filename{.*}.:ext"))) + (test-equal "/static/(.*)\\.([^/.]+)" path) + (test-equal '(filename ext) args)) |