feat: 서버는 기초의 테스트 더함
Some checks failed
build / build (push) Failing after 33s

This commit is contained in:
2026-03-23 09:38:42 -06:00
parent 79735cc0ba
commit e11d7d4671
5 changed files with 41 additions and 5 deletions

View File

@@ -20,4 +20,8 @@ mkCljBin {
bb -cp . -m override-deps < deps.edn.old > deps.edn \
net.deertopia/doerg '{:local/root "${doerg.lib}/${doerg.name}.jar"}'
'';
doCheck = true;
checkPhase = ''
clojure -M:test
'';
}

View File

@@ -13,4 +13,7 @@
http-kit/http-kit {:mvn/version "2.8.0"}
instaparse/instaparse {:mvn/version "1.5.0"}
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"]}}}

View File

@@ -98,8 +98,7 @@
(defn start! []
(if @server
(let [msg "Server already started"]
(throw (ex-info msg {})))
(throw (IllegalStateException. "Server already started"))
(do (reset! server
(http/run-server (bound-fn* #'app)
{:port (-> cfg/*cfg* ::publisher/port)
@@ -107,8 +106,13 @@
;; For some reason, the log messages are not flushed before
;; the JVM shuts dowm. Nevertheless, the server /does/ come
;; to a graceful halt.
(.addShutdownHook (Runtime/getRuntime) shutdown-hook)
(l/info "Server started on port 8080"))))
(try (.addShutdownHook (Runtime/getRuntime) shutdown-hook)
(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 []
(if @server

View 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
View File

@@ -0,0 +1 @@
#kaocha/v1 {}