diff --git a/lack-component.asd b/lack-component.asd index 989229d..2bc6fe2 100644 --- a/lack-component.asd +++ b/lack-component.asd @@ -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)))) diff --git a/t-lack-component.asd b/t-lack-component.asd new file mode 100644 index 0000000..3976289 --- /dev/null +++ b/t-lack-component.asd @@ -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))) diff --git a/t/component.lisp b/t/component.lisp new file mode 100644 index 0000000..a000e34 --- /dev/null +++ b/t/component.lisp @@ -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)