diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-10-18 22:33:18 +0200 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2024-10-18 22:33:18 +0200 |
commit | b6ddbf68b5daab7faf431c5242eaf704169a7942 (patch) | |
tree | 00e32890a193f0d1559885f1eca938efb2d51770 /tests | |
parent | bd07f91d1f2ad91f53789f993c75e3c794f48a56 (diff) |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-routes.lisp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/test-routes.lisp b/tests/test-routes.lisp index 45f75cc..21cc687 100644 --- a/tests/test-routes.lisp +++ b/tests/test-routes.lisp @@ -2,7 +2,8 @@ (5am:def-suite* scgi-routes-tests) -(5am:test test1 +;;; Check variable binding +(5am:test variable-binding (5am:finishes (routes:define-route index (:path (p1 p2 "index.cgi") :method :get @@ -23,3 +24,31 @@ (setf ret (test-route :get uri))) ret) (list "foo" "blah" nil "2" nil "4" t nil t nil)))) + + +(defun scgi-header (field-alist) + (let ((headers + (with-output-to-string (*standard-output*) + (dolist (entry field-alist) + (format t "~A~C~A~C" (car entry) #\Nul (cdr entry) #\Nul))))) + (concatenate 'string + (format nil "~D:" (length headers)) + headers + (string #\Nul)))) + +;;; Check that unhandled exceptions don't crash the server +(5am:test condition-handling + (5am:finishes + (routes:define-route route-test2 (:path ("index.cgi") + :method :get) + (error "error-route-test2"))) + (5am:finishes + (let ((header (scgi-header '(("SCGI" . "1") + ("REQUEST_METHOD" . "GET") + ("REQUEST_URI" . "/index.cgi"))))) + (with-input-from-string (input header) + (with-output-to-string (output) + (let ((*error-output* output)) + (routes::socket-function (make-two-way-stream input output) + #'routes::default-error-handler + #'routes::default-internal-error-handler))))))) |