This commit is contained in:
@@ -20,4 +20,8 @@ mkCljBin {
|
|||||||
bb -cp . -m override-deps < deps.edn.old > deps.edn \
|
bb -cp . -m override-deps < deps.edn.old > deps.edn \
|
||||||
net.deertopia/doerg '{:local/root "${doerg.lib}/${doerg.name}.jar"}'
|
net.deertopia/doerg '{:local/root "${doerg.lib}/${doerg.name}.jar"}'
|
||||||
'';
|
'';
|
||||||
|
doCheck = true;
|
||||||
|
checkPhase = ''
|
||||||
|
clojure -M:test
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,7 @@
|
|||||||
http-kit/http-kit {:mvn/version "2.8.0"}
|
http-kit/http-kit {:mvn/version "2.8.0"}
|
||||||
instaparse/instaparse {:mvn/version "1.5.0"}
|
instaparse/instaparse {:mvn/version "1.5.0"}
|
||||||
aero/aero {:mvn/version "1.1.6"}}
|
aero/aero {:mvn/version "1.1.6"}}
|
||||||
:paths ["src" "resources" "test"]}
|
:paths ["src" "resources" "test"]
|
||||||
|
:aliases
|
||||||
|
{:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
|
||||||
|
:main-opts ["-m" "kaocha.runner"]}}}
|
||||||
|
|||||||
@@ -98,8 +98,7 @@
|
|||||||
|
|
||||||
(defn start! []
|
(defn start! []
|
||||||
(if @server
|
(if @server
|
||||||
(let [msg "Server already started"]
|
(throw (IllegalStateException. "Server already started"))
|
||||||
(throw (ex-info msg {})))
|
|
||||||
(do (reset! server
|
(do (reset! server
|
||||||
(http/run-server (bound-fn* #'app)
|
(http/run-server (bound-fn* #'app)
|
||||||
{:port (-> cfg/*cfg* ::publisher/port)
|
{:port (-> cfg/*cfg* ::publisher/port)
|
||||||
@@ -107,8 +106,13 @@
|
|||||||
;; For some reason, the log messages are not flushed before
|
;; For some reason, the log messages are not flushed before
|
||||||
;; the JVM shuts dowm. Nevertheless, the server /does/ come
|
;; the JVM shuts dowm. Nevertheless, the server /does/ come
|
||||||
;; to a graceful halt.
|
;; to a graceful halt.
|
||||||
(.addShutdownHook (Runtime/getRuntime) shutdown-hook)
|
(try (.addShutdownHook (Runtime/getRuntime) shutdown-hook)
|
||||||
(l/info "Server started on port 8080"))))
|
(catch IllegalArgumentException e
|
||||||
|
(when (not= "Hook previously registered"
|
||||||
|
(ex-message e))
|
||||||
|
(throw e))))
|
||||||
|
(l/infof "Server started on port %d"
|
||||||
|
(-> cfg/*cfg* ::publisher/port)))))
|
||||||
|
|
||||||
(defn status []
|
(defn status []
|
||||||
(if @server
|
(if @server
|
||||||
|
|||||||
24
publisher/test/net/deertopia/publisher/server_test.clj
Normal file
24
publisher/test/net/deertopia/publisher/server_test.clj
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
(ns net.deertopia.publisher.server-test
|
||||||
|
(:require [net.deertopia.publisher.server :as sut]
|
||||||
|
[reitit.ring]
|
||||||
|
[clojure.test :as t]
|
||||||
|
[clojure.set :as set]
|
||||||
|
[net.deertopia.publisher.server :as server]
|
||||||
|
[net.deertopia.publisher.config :as cfg]
|
||||||
|
[net.deertopia.publisher :as-alias publisher]))
|
||||||
|
|
||||||
|
(t/deftest server-is-running
|
||||||
|
;; 서버는 시작 전에 이 검서 하면 고장 있습니다.
|
||||||
|
(assert (not= :running (server/status)))
|
||||||
|
(server/start!)
|
||||||
|
(t/is (= :running (server/status)))
|
||||||
|
(server/stop!))
|
||||||
|
|
||||||
|
(t/deftest can-get-real-server-root
|
||||||
|
;; 서버는 시작 전에 이 검서 하면 고장 있습니다.
|
||||||
|
(assert (not= :running (server/status)))
|
||||||
|
(server/start!)
|
||||||
|
(t/is (->> (format "http://localhost:%d" (::publisher/port cfg/*cfg*))
|
||||||
|
slurp
|
||||||
|
string?))
|
||||||
|
(server/stop!))
|
||||||
1
publisher/tests.edn
Normal file
1
publisher/tests.edn
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#kaocha/v1 {}
|
||||||
Reference in New Issue
Block a user