feat: 서버는 기초의 테스트 더함
All checks were successful
build / build (push) Successful in 1m35s

This commit is contained in:
2026-03-24 14:58:31 -06:00
parent 79735cc0ba
commit e73148ef3d
7 changed files with 57 additions and 35 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

@@ -7,10 +7,14 @@
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}
org.xerial/sqlite-jdbc {:mvn/version "3.47.1.0"}
cheshire/cheshire {:mvn/version "6.1.0"}
org.clojure/test.check {:mvn/version "1.1.2"}
org.clojure/test.check {:mvn/version "1.1.3"}
net.deertopia/doerg {:local/root "../doerg"}
metosin/reitit {:mvn/version "0.10.1"}
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"]
:aliases
{:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.91.1392"}}
:extra-paths ["test"]
: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 {}