Files
net-deertopia/test/net/deertopia/doerg/server_test.clj
Madeleine Sydney Ślaga dcaac98252
All checks were successful
build / build (push) Successful in 5s
refactor: doerg는 publisher와 결합
2026-04-03 13:31:16 -06:00

53 lines
1.6 KiB
Clojure
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(ns net.deertopia.doerg.server-test
(:require [net.deertopia.doerg.server :as sut]
[reitit.ring]
[clojure.test :as t]
[net.deertopia.doerg.config :as cfg]
[net.deertopia.doerg.roam :as roam]
[babashka.fs :as fs]
[clojure.java.io :as io]
[net.deertopia.doerg.roam-test :refer [test-db-fixture]]
[net.deertopia.doerg.config-test :refer [test-config-fixture]]))
(t/use-fixtures
:once (t/join-fixtures [test-config-fixture test-db-fixture]))
(defn with-server [f]
(let [was-already-running? (= :running (sut/status))]
(when-not was-already-running?
(sut/start!))
(f)
(when-not was-already-running?
(sut/stop!))))
(defn get-sut [uri]
(sut/app {:request-method :get
:uri uri}))
(t/deftest server-is-running
;; 서버는 벌써 시작한 다음에 이 테스트 하면 잘못됩니다.
;; (assert (not= :running (sut/status)))
(with-server
(fn []
(t/is (= :running (sut/status)))
(t/is (->> (format "http://localhost:%d"
(::cfg/port cfg/*cfg*))
slurp
string?)))))
(t/deftest get-nonexistent-node
(let [slug "3Lxvxnb0QrivoU3DX-l_5w"]
(assert (nil? (roam/make-node slug)))
(t/is (= 404
(-> (str "/n/" slug)
get-sut :status)))))
(t/deftest get-homepage
(let [resp (-> (str "/n/" sut/homepage-slug)
get-sut)]
(t/is (= 200 (:status resp)))
(t/is (= (-> "/" get-sut :body)
(-> resp :body)))))