From 07fb0fc83688d1fb55c7e3b0b4ce8ef6e988cbfe Mon Sep 17 00:00:00 2001 From: Eitaro Fukamachi Date: Tue, 24 Mar 2015 15:38:18 +0900 Subject: [PATCH] Add tests of lack-component. --- lack-component.asd | 3 ++- t-lack-component.asd | 17 +++++++++++++++++ t/component.lisp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 t-lack-component.asd create mode 100644 t/component.lisp 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)