해결 #28
This commit was merged in pull request #30.
This commit is contained in:
8
publisher/test/net/deertopia/publisher/org-roam-db-sync.el
Executable file
8
publisher/test/net/deertopia/publisher/org-roam-db-sync.el
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env -S emacs -Q -x
|
||||
|
||||
(require 'org-roam)
|
||||
|
||||
(setq org-roam-directory (expand-file-name (car command-line-args-left)))
|
||||
(setq org-roam-db-location (expand-file-name (cadr command-line-args-left)))
|
||||
|
||||
(org-roam-db-sync)
|
||||
Binary file not shown.
@@ -6,7 +6,13 @@
|
||||
[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]))
|
||||
[net.deertopia.publisher.roam :as roam]
|
||||
[babashka.fs :as fs]
|
||||
[babashka.process :as p]
|
||||
[clojure.java.io :as io]))
|
||||
|
||||
(def org-roam-directory
|
||||
(fs/file "test/net/deertopia/publisher/roam-test"))
|
||||
|
||||
(defn config-fixture [f]
|
||||
(binding [doerg-cfg/*cfg*
|
||||
@@ -19,8 +25,27 @@
|
||||
:profile :test)]
|
||||
(f)))
|
||||
|
||||
(defn org-roam-db-sync [db-file]
|
||||
(let [script-file (fs/create-temp-file {:prefix "org-roam-db-sync-"
|
||||
:suffix ".el"})
|
||||
emacs (->> [(System/getenv "EMACS") "test-emacs" "emacs"]
|
||||
(some #(some-> % fs/which)))]
|
||||
(io/copy (-> "net/deertopia/publisher/org-roam-db-sync.el"
|
||||
io/resource io/reader)
|
||||
(fs/file script-file))
|
||||
(p/shell {:out :string :err :string}
|
||||
emacs "-Q" "-x" script-file org-roam-directory db-file)
|
||||
(fs/delete script-file)))
|
||||
|
||||
(defn test-db-fixture [f]
|
||||
(let [db-file (-> publisher-cfg/*cfg* ::publisher/org-roam-db-path)]
|
||||
(fs/delete-if-exists db-file)
|
||||
(org-roam-db-sync db-file)
|
||||
(f)
|
||||
(fs/delete db-file)))
|
||||
|
||||
(t/use-fixtures
|
||||
:once config-fixture)
|
||||
:once (t/join-fixtures [config-fixture test-db-fixture]))
|
||||
|
||||
(defn with-server [f]
|
||||
(let [was-already-running? (= :running (sut/status))]
|
||||
@@ -34,6 +59,8 @@
|
||||
(sut/app {:request-method :get
|
||||
:uri uri}))
|
||||
|
||||
|
||||
|
||||
(t/deftest server-is-running
|
||||
;; 서버는 벌써 시작한 다음에 이 테스트 하면 잘못됩니다.
|
||||
;; (assert (not= :running (sut/status)))
|
||||
@@ -41,25 +68,23 @@
|
||||
(fn []
|
||||
(t/is (= :running (sut/status)))
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
#_(t/is (->> (format "http://localhost:%d"
|
||||
(t/is (->> (format "http://localhost:%d"
|
||||
(::publisher/port publisher-cfg/*cfg*))
|
||||
slurp
|
||||
string?)))))
|
||||
|
||||
(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))))))
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(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))))))
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(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