mirror of
https://github.com/vale981/lack
synced 2025-03-04 17:01:41 -05:00
Add tests of lack-util.
This commit is contained in:
parent
d4ef9abc2e
commit
127aa16e32
3 changed files with 61 additions and 1 deletions
|
@ -9,4 +9,5 @@
|
||||||
:license "LLGPL"
|
:license "LLGPL"
|
||||||
:depends-on (:ironclad
|
:depends-on (:ironclad
|
||||||
:alexandria)
|
:alexandria)
|
||||||
:components ((:file "src/util")))
|
:components ((:file "src/util"))
|
||||||
|
:in-order-to ((test-op (test-op t-lack-util))))
|
||||||
|
|
17
t-lack-util.asd
Normal file
17
t-lack-util.asd
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
(in-package :cl-user)
|
||||||
|
(defpackage t-lack-util-asd
|
||||||
|
(:use :cl :asdf))
|
||||||
|
(in-package :t-lack-util-asd)
|
||||||
|
|
||||||
|
(defsystem t-lack-util
|
||||||
|
:author "Eitaro Fukamachi"
|
||||||
|
:license "LLGPL"
|
||||||
|
:depends-on (:lack-test
|
||||||
|
:lack-util
|
||||||
|
:prove)
|
||||||
|
:components
|
||||||
|
((:test-file "t/util"))
|
||||||
|
|
||||||
|
:defsystem-depends-on (:prove-asdf)
|
||||||
|
:perform (test-op :after (op c)
|
||||||
|
(funcall (intern #.(string :run-test-system) :prove) c)))
|
42
t/util.lisp
Normal file
42
t/util.lisp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
(in-package :cl-user)
|
||||||
|
(defpackage t.lack.util
|
||||||
|
(:use :cl
|
||||||
|
:prove
|
||||||
|
:lack.util
|
||||||
|
:lack.test))
|
||||||
|
(in-package :t.lack.util)
|
||||||
|
|
||||||
|
(plan 2)
|
||||||
|
|
||||||
|
(subtest "find-package-or-load"
|
||||||
|
(is (find-package-or-load "LACK")
|
||||||
|
(find-package :lack))
|
||||||
|
(is (find-package-or-load "hoge") nil))
|
||||||
|
|
||||||
|
(subtest "funcall-with-cb"
|
||||||
|
(let ((cb (lambda (res)
|
||||||
|
(rplacd (car (last res)) (list "(ok from cb)"))
|
||||||
|
res)))
|
||||||
|
;; cons
|
||||||
|
(let ((app (lambda (env)
|
||||||
|
(declare (ignore env))
|
||||||
|
'(200 (:content-type "text/plain") ("ok")))))
|
||||||
|
(is (funcall-with-cb app (generate-env "/") cb)
|
||||||
|
'(200 (:content-type "text/plain") ("ok" "(ok from cb)"))))
|
||||||
|
;; function
|
||||||
|
(let* ((app (lambda (env)
|
||||||
|
(declare (ignore env))
|
||||||
|
(lambda (responder)
|
||||||
|
(funcall responder '(200 (:content-type "text/plain") ("ok"))))))
|
||||||
|
(cb-res (funcall-with-cb app (generate-env "/") cb)))
|
||||||
|
(is-type cb-res 'function)
|
||||||
|
(let (res)
|
||||||
|
(funcall cb-res (lambda (r) (setf res r)))
|
||||||
|
(is res '(200 (:content-type "text/plain") ("ok" "(ok from cb)")))))
|
||||||
|
;; otherwise
|
||||||
|
(let ((app (lambda (env)
|
||||||
|
(declare (ignore env))
|
||||||
|
1)))
|
||||||
|
(is (funcall-with-cb app (generate-env "/") cb) 1))))
|
||||||
|
|
||||||
|
(finalize)
|
Loading…
Add table
Reference in a new issue