Compare commits
1 Commits
de61e45637
...
9cc0def4d5
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cc0def4d5 |
@@ -12,13 +12,10 @@
|
||||
|
||||
(defonce ^:dynamic *use-db-cache?* true)
|
||||
|
||||
(def db-path (-> cfg/*cfg* ::publisher/org-roam-db-path
|
||||
fs/expand-home str))
|
||||
|
||||
(def db {:dbtype "sqlite"
|
||||
:dbname db-path})
|
||||
|
||||
(def ds (sql/get-datasource db))
|
||||
(defn- ds []
|
||||
(sql/get-datasource
|
||||
{:dbtype "sqlite"
|
||||
:dbname (-> cfg/*cfg* ::publisher/org-roam-db-path str)}))
|
||||
|
||||
|
||||
;;; Elisp sexp (de)serialisation
|
||||
@@ -38,7 +35,7 @@
|
||||
(defrecord Node [id cache])
|
||||
|
||||
(defn- uuid-exists? [uuid]
|
||||
(sql/execute-one! ds
|
||||
(sql/execute-one! (ds)
|
||||
["select 1 from nodes where id = ? limit 1"
|
||||
(-> uuid str elisp/print)]))
|
||||
|
||||
@@ -59,7 +56,7 @@
|
||||
node :org-file
|
||||
(fn [node]
|
||||
(when-some [r (sql/execute-one!
|
||||
ds
|
||||
(ds)
|
||||
["select file from nodes where id = ?"
|
||||
(-> node :id str elisp/print)])]
|
||||
(-> r :nodes/file elisp/read-string)))))
|
||||
@@ -90,7 +87,7 @@
|
||||
(fetch-with-cache
|
||||
node :title
|
||||
#(do (println "fetch")
|
||||
(sql/execute-one! ds ["select title from nodes where id = ?"
|
||||
(sql/execute-one! (ds) ["select title from nodes where id = ?"
|
||||
(elisp/print (:id %))]))))
|
||||
|
||||
|
||||
@@ -100,7 +97,7 @@
|
||||
(fetch-with-cache
|
||||
node :level
|
||||
#(-> (sql/execute-one!
|
||||
ds ["select level from nodes where id = ?"
|
||||
(ds) ["select level from nodes where id = ?"
|
||||
(print-id %)])
|
||||
:nodes/level)))
|
||||
|
||||
@@ -111,7 +108,7 @@
|
||||
(fetch-with-cache
|
||||
node :file
|
||||
#(-> (sql/execute-one!
|
||||
ds ["select file from nodes where id = ?"
|
||||
(ds) ["select file from nodes where id = ?"
|
||||
(print-id %)])
|
||||
:nodes/file
|
||||
elisp/read-string)))
|
||||
@@ -120,7 +117,7 @@
|
||||
(fetch-with-cache
|
||||
node :properties
|
||||
#(-> (sql/execute-one!
|
||||
ds ["select properties from nodes where id = ?"
|
||||
(ds) ["select properties from nodes where id = ?"
|
||||
(print-id %)])
|
||||
:nodes/properties
|
||||
elisp/read-alist)))
|
||||
@@ -136,7 +133,7 @@
|
||||
"Returns a collection of maps {:id …, :title …}."
|
||||
[node]
|
||||
(for [{id :nodes/id, title :nodes/title}
|
||||
(sql/execute! ds ["select distinct nodes.id, nodes.title from links
|
||||
(sql/execute! (ds) ["select distinct nodes.id, nodes.title from links
|
||||
inner join nodes
|
||||
on nodes.id = links.source
|
||||
where links.dest = ?"
|
||||
@@ -156,9 +153,9 @@
|
||||
(-> uuid parse-uuid get-node graph-visible?))
|
||||
|
||||
(defn get-graph []
|
||||
(let [nodes (sql/execute! ds ["select id, title from nodes"])
|
||||
(let [nodes (sql/execute! (ds) ["select id, title from nodes"])
|
||||
links (sql/execute!
|
||||
ds
|
||||
(ds)
|
||||
["select n1.id as source, nodes.id as target from
|
||||
((nodes as n1) join links on n1.id = links.source)
|
||||
join (nodes as n2) on links.dest = nodes.id
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
:PROPERTIES:
|
||||
:ID: ebc5ea84-77ab-4d60-9b13-ef9160b11d1f
|
||||
:END:
|
||||
#+title: deertopia.net!!!!!!!!
|
||||
|
||||
homeee
|
||||
@@ -8,8 +8,7 @@
|
||||
[net.deertopia.doerg :as-alias doerg]
|
||||
[net.deertopia.publisher.roam :as roam]))
|
||||
|
||||
(t/use-fixtures
|
||||
:once (fn [f]
|
||||
(defn config-fixture [f]
|
||||
(binding [doerg-cfg/*cfg*
|
||||
(doerg-cfg/read-config
|
||||
::doerg/config doerg-cfg/sources
|
||||
@@ -18,7 +17,10 @@
|
||||
(doerg-cfg/read-config
|
||||
::publisher/config publisher-cfg/sources
|
||||
:profile :test)]
|
||||
(f))))
|
||||
(f)))
|
||||
|
||||
(t/use-fixtures
|
||||
:once config-fixture)
|
||||
|
||||
(defn with-server [f]
|
||||
(let [was-already-running? (= :running (sut/status))]
|
||||
@@ -38,21 +40,26 @@
|
||||
(with-server
|
||||
(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)))))
|
||||
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)))))
|
||||
(-> resp :body))))))
|
||||
|
||||
Reference in New Issue
Block a user