cl-scopes/test/test-web.lisp

39 lines
1.2 KiB
Common Lisp

;;;; cl-scopes/test-web - test web (client and server) functionality
(defpackage :scopes/test-web
(:use :common-lisp)
(:local-nicknames (:config :scopes/config)
(:core :scopes/core)
(:client :scopes/web/client)
(:message :scopes/core/message)
(:server :scopes/web/server)
(:t :scopes/testing))
(:export #:run)
(:import-from :scopes/testing #:deftest #:==))
(in-package :scopes/test-web)
(defvar *config* nil)
(defun run ()
(let ((t:*test-suite* (t:test-suite "web"))
(*config* nil)
(server:*listener* nil))
(load (t:test-path "config-web" "etc"))
(core:setup-services *config*)
(test-server-config)
(sleep 0.1)
(test-client)
(sleep 0.1)
(server:stop)
(t:show-result)))
(t:deftest test-server-config ()
(let ((cfg (core:config (core:find-service :server))))
(== (parse-integer (server:port cfg)) 8899)))
(t:deftest test-client ()
(let ((ctx (core:find-service :client))
(msg (message:simple-message '(:test :get-page) '(:path "demo.html"))))
(== (client:base-url (core:config ctx)) "http://localhost:8899")
(== (client:get-page ctx msg) "Hello World!")))