Add tests of lack-component.

This commit is contained in:
Eitaro Fukamachi 2015-03-24 15:38:18 +09:00
parent 127aa16e32
commit 07fb0fc836
3 changed files with 50 additions and 1 deletions

View file

@ -7,4 +7,5 @@
:version "0.1"
:author "Eitaro Fukamachi"
:license "LLGPL"
:components ((:file "src/component")))
:components ((:file "src/component"))
:in-order-to ((test-op (test-op t-lack-component))))

17
t-lack-component.asd Normal file
View file

@ -0,0 +1,17 @@
(in-package :cl-user)
(defpackage t-lack-component-asd
(:use :cl :asdf))
(in-package :t-lack-component-asd)
(defsystem t-lack-component
:author "Eitaro Fukamachi"
:license "LLGPL"
:depends-on (:lack-component
:lack-test
:prove)
:components
((:test-file "t/component"))
:defsystem-depends-on (:prove-asdf)
:perform (test-op :after (op c)
(funcall (intern #.(string :run-test-system) :prove) c)))

31
t/component.lisp Normal file
View file

@ -0,0 +1,31 @@
(in-package :cl-user)
(defpackage t.lack.component
(:use :cl
:lack.component
:lack.test
:prove))
(in-package :t.lack.component)
(plan 4)
(defclass myapp (lack-component) ())
(defmethod call ((comp myapp) env)
(declare (ignore env))
'(200
(:content-type "text/plain")
("ok from myapp")))
(defvar *fn-app*
(lambda (env)
`(200 (:content-type "text/plain") ("ok" ,(getf env :path-info)))))
(is (call *fn-app* (generate-env "/hello"))
'(200 (:content-type "text/plain") ("ok" "/hello")))
(is (call (make-instance 'myapp) (generate-env "/"))
'(200 (:content-type "text/plain") ("ok from myapp")))
(is-type (to-app *fn-app*) 'function)
(is-type (to-app (make-instance 'myapp)) 'function)
(finalize)