71 lines
2.4 KiB
Common Lisp
71 lines
2.4 KiB
Common Lisp
|
(defpackage cl-gemini/tests/main
|
||
|
(:use :cl
|
||
|
:cl-gemini
|
||
|
:rove))
|
||
|
|
||
|
(in-package :cl-gemini/tests/main)
|
||
|
|
||
|
;; NOTE: To run this test file, execute `(asdf:test-system :cl-gemini)' in your Lisp.
|
||
|
|
||
|
(deftest create-errors
|
||
|
(testing "temporary-redirect"
|
||
|
(ok (= (response/status-code
|
||
|
(error/temporary-redirect "gemini://nowhere"))
|
||
|
30)))
|
||
|
(testing "permanent-redirect"
|
||
|
(ok (= (response/status-code
|
||
|
(error/permanent-redirect "gemini://nowhere"))
|
||
|
31)))
|
||
|
(testing "temporary-failure"
|
||
|
(ok (= (response/status-code
|
||
|
(error/temporary-failure))
|
||
|
40)))
|
||
|
(testing "permanent-failure"
|
||
|
(ok (= (response/status-code
|
||
|
(error/permanent-failure))
|
||
|
50)))
|
||
|
(testing "success-code"
|
||
|
(ok (= (response/status-code
|
||
|
(success "Hello World!"))
|
||
|
20)))
|
||
|
(testing "success-terminate-code"
|
||
|
(ok (= (response/status-code
|
||
|
(success/end-session "Hello World!"))
|
||
|
21))))
|
||
|
|
||
|
(deftest test-portal
|
||
|
(testing "portal-closed"
|
||
|
(ok (let ((portal (test/portal))
|
||
|
(err (error/temporary-failure "hi")))
|
||
|
(progn (response/write portal err)
|
||
|
(test/closed-p portal))))))
|
||
|
|
||
|
(deftest check-output
|
||
|
(testing "simple-header"
|
||
|
(ok (let ((portal (test/portal))
|
||
|
(err (error/temporary-failure)))
|
||
|
(progn (response/write portal err)
|
||
|
(string= (test/output portal)
|
||
|
(format nil "40 TEMPORARY-FAILURE<BREAK>~%"))))))
|
||
|
|
||
|
(testing "header-with-message"
|
||
|
(ok (let ((portal (test/portal))
|
||
|
(err (error/temporary-failure "hi")))
|
||
|
(progn (response/write portal err)
|
||
|
(string= (test/output portal)
|
||
|
(format nil "40 TEMPORARY-FAILURE: hi<BREAK>~%"))))))
|
||
|
|
||
|
(testing "success-output"
|
||
|
(ok (let ((portal (test/portal))
|
||
|
(resp (success "Oh hello there!")))
|
||
|
(progn (response/write portal resp)
|
||
|
(string= (test/output portal)
|
||
|
(format nil "20 SUCCESS<BREAK>~%Oh hello there!<BREAK>~%"))))))
|
||
|
|
||
|
(testing "success/end-session-output"
|
||
|
(ok (let ((portal (test/portal))
|
||
|
(resp (success/end-session "Oh hello there!")))
|
||
|
(progn (response/write portal resp)
|
||
|
(string= (test/output portal)
|
||
|
(format nil "21 SUCCESS-END-OF-CLIENT-CERTIFICATE-SESSION<BREAK>~%Oh hello there!<BREAK>~%")))))))
|