mirror of
https://github.com/vale981/lack
synced 2025-03-06 01:41:39 -05:00
Add tests for lack.builder.
This commit is contained in:
parent
1e90c27aec
commit
1e58de2f84
3 changed files with 51 additions and 15 deletions
|
@ -15,7 +15,7 @@
|
||||||
:prove)
|
:prove)
|
||||||
:components ((:module "t"
|
:components ((:module "t"
|
||||||
:components
|
:components
|
||||||
((:test-file "lack"))))
|
((:test-file "builder"))))
|
||||||
|
|
||||||
:defsystem-depends-on (:prove-asdf)
|
:defsystem-depends-on (:prove-asdf)
|
||||||
:perform (test-op :after (op c)
|
:perform (test-op :after (op c)
|
||||||
|
|
50
t/builder.lisp
Normal file
50
t/builder.lisp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
(in-package :cl-user)
|
||||||
|
(defpackage t.lack.builder
|
||||||
|
(:use :cl
|
||||||
|
:prove
|
||||||
|
:lack.builder))
|
||||||
|
(in-package :t.lack.builder)
|
||||||
|
|
||||||
|
(plan 8)
|
||||||
|
|
||||||
|
(defvar *app*
|
||||||
|
(lambda (env)
|
||||||
|
(declare (ignore env))
|
||||||
|
'(200 (:content-type "text/html") ("ok from app"))))
|
||||||
|
|
||||||
|
(is-type (builder (lambda (app)
|
||||||
|
(lambda (env)
|
||||||
|
(funcall app env)))
|
||||||
|
*app*)
|
||||||
|
'function
|
||||||
|
"builder")
|
||||||
|
|
||||||
|
(is-type (builder
|
||||||
|
(if t
|
||||||
|
(lambda (app)
|
||||||
|
(lambda (env)
|
||||||
|
(funcall app env)))
|
||||||
|
nil)
|
||||||
|
*app*)
|
||||||
|
'function
|
||||||
|
"Can embed CL code")
|
||||||
|
|
||||||
|
(is-type (builder nil (if t nil nil) nil *app*)
|
||||||
|
'function
|
||||||
|
"NIL is ignored")
|
||||||
|
|
||||||
|
(let ((mount-app (builder
|
||||||
|
(:mount "/admin" (lambda (env) `(200 () ("admin" ,(getf env :path-info)))))
|
||||||
|
*app*)))
|
||||||
|
(is (nth 2 (funcall mount-app '(:path-info "/login")))
|
||||||
|
'("ok from app"))
|
||||||
|
(is (nth 2 (funcall mount-app '(:path-info "/admin/login")))
|
||||||
|
'("admin" "/login"))
|
||||||
|
(is (nth 2 (funcall mount-app '(:path-info "/admin")))
|
||||||
|
'("admin" "/"))
|
||||||
|
(is (nth 2 (funcall mount-app '(:path-info "/admin/")))
|
||||||
|
'("admin" "/"))
|
||||||
|
(is (nth 2 (funcall mount-app '(:path-info "/administrators")))
|
||||||
|
'("ok from app")))
|
||||||
|
|
||||||
|
(finalize)
|
14
t/lack.lisp
14
t/lack.lisp
|
@ -1,14 +0,0 @@
|
||||||
(in-package :cl-user)
|
|
||||||
(defpackage t.lack
|
|
||||||
(:use :cl
|
|
||||||
:lack
|
|
||||||
:prove))
|
|
||||||
(in-package :t.lack)
|
|
||||||
|
|
||||||
;; NOTE: To run this test file, execute `(asdf:test-system :lack)' in your Lisp.
|
|
||||||
|
|
||||||
(plan nil)
|
|
||||||
|
|
||||||
;; blah blah blah.
|
|
||||||
|
|
||||||
(finalize)
|
|
Loading…
Add table
Reference in a new issue