-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added "clack.test" for unit testing Clack Applications. and rewrote "…
…clack.test.suite" with it.
- Loading branch information
Showing
3 changed files
with
227 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#| | ||
This file is a part of Clack package. | ||
URL: http://github.com/fukamachi/clack | ||
Copyright (c) 2011 Eitarow Fukamachi <e.arrows@gmail.com> | ||
Clack is freely distributable under the LLGPL License. | ||
|# | ||
|
||
#| | ||
Testing Clack Applications. | ||
Author: Eitarow Fukamachi (e.arrows@gmail.com) | ||
|# | ||
|
||
(in-package :cl-user) | ||
|
||
(defpackage :clack.test | ||
(:use :cl | ||
:cl-test-more) | ||
(:export :test-app | ||
:define-app-test | ||
:*clack-test-handler* | ||
:*clack-test-port*)) | ||
|
||
(in-package :clack.test) | ||
|
||
(defvar *clack-test-handler* 'clack.handler.hunchentoot | ||
"Backend Handler to run tests on. String or Symbol are allowed.") | ||
|
||
(defvar *clack-test-port* 8080 | ||
"HTTP port number of Handler.") | ||
|
||
(defun test-app (desc app client) | ||
"Test Clack Application." | ||
(let* ((handler | ||
(or (find-package *clack-test-handler*) | ||
(error "Handler package is not found. Forgot to load it?: ~A" | ||
*clack-test-handler*))) | ||
(acceptor (funcall (intern "RUN" handler) | ||
app :port *clack-test-port* :debug t))) | ||
(when desc (diag desc)) | ||
(unwind-protect | ||
(funcall client) | ||
(funcall (intern "STOP" handler) acceptor)))) | ||
|
||
(defmacro define-app-test (desc app client) | ||
`(cl-test-more::deftest ,(intern desc) | ||
(test-app nil ,app ,client))) |
Oops, something went wrong.