This commit was merged in pull request #27.
This commit is contained in:
BIN
publisher/test/net/deertopia/publisher/roam-test.db
Normal file
BIN
publisher/test/net/deertopia/publisher/roam-test.db
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
:PROPERTIES:
|
||||
:ID: 23ee464d-b13e-4649-826f-622d0edef24e
|
||||
:DeertopiaVisibility: public
|
||||
:END:
|
||||
#+title: awesome file
|
||||
|
||||
wow!
|
||||
@@ -0,0 +1,6 @@
|
||||
:PROPERTIES:
|
||||
:ID: ebc5ea84-77ab-4d60-9b13-ef9160b11d1f
|
||||
:END:
|
||||
#+title: deertopia.net!!!!!!!!
|
||||
|
||||
homeee
|
||||
@@ -2,23 +2,64 @@
|
||||
(: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]))
|
||||
[net.deertopia.publisher.config :as publisher-cfg]
|
||||
[net.deertopia.doerg.config :as doerg-cfg]
|
||||
[net.deertopia.publisher :as-alias publisher]
|
||||
[net.deertopia.doerg :as-alias doerg]
|
||||
[net.deertopia.publisher.roam :as roam]))
|
||||
|
||||
(defn config-fixture [f]
|
||||
(binding [doerg-cfg/*cfg*
|
||||
(doerg-cfg/read-config
|
||||
::doerg/config doerg-cfg/sources
|
||||
:profile :test)
|
||||
publisher-cfg/*cfg*
|
||||
(doerg-cfg/read-config
|
||||
::publisher/config publisher-cfg/sources
|
||||
:profile :test)]
|
||||
(f)))
|
||||
|
||||
(t/use-fixtures
|
||||
:once config-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 (server/status)))
|
||||
(server/start!)
|
||||
(t/is (= :running (server/status)))
|
||||
(server/stop!))
|
||||
;; 서버는 벌써 시작한 다음에 이 테스트 하면 잘못됩니다.
|
||||
;; (assert (not= :running (sut/status)))
|
||||
(with-server
|
||||
(fn []
|
||||
(t/is (= :running (sut/status)))
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
#_(t/is (->> (format "http://localhost:%d"
|
||||
(::publisher/port publisher-cfg/*cfg*))
|
||||
slurp
|
||||
string?)))))
|
||||
|
||||
(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!))
|
||||
(comment
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(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))))))
|
||||
|
||||
(comment
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(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))))))
|
||||
|
||||
Reference in New Issue
Block a user