aboutsummaryrefslogtreecommitdiff
path: root/tests/server.scm
blob: d21c11da7ad7801f202c79df67c74bb89ac758e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;;; Commentary:
;; Tests parse-endpoint-string, used for defining server routes.
;;; Code:

(((web http make-routes) parse-endpoint-string)
 ((calp util) 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))