This commit is contained in:
@@ -30,7 +30,6 @@ in mkCljBin' {
|
||||
];
|
||||
nativeBuildInputs = [
|
||||
babashka
|
||||
breakpointHook
|
||||
];
|
||||
nativeCheckInputs = [
|
||||
doerg-parser
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
(defonce ^:dynamic *use-db-cache?* true)
|
||||
|
||||
(defn- ds []
|
||||
(defn ds []
|
||||
(sql/get-datasource
|
||||
{:dbtype "sqlite"
|
||||
:dbname (-> cfg/*cfg* ::publisher/org-roam-db-path str)}))
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
(defrecord Node [id cache])
|
||||
|
||||
(defn- uuid-exists? [uuid]
|
||||
(defn uuid-exists? [uuid]
|
||||
(sql/execute-one! (ds)
|
||||
["select 1 from nodes where id = ? limit 1"
|
||||
(-> uuid str elisp/print)]))
|
||||
|
||||
19
publisher/test/net/deertopia/publisher/config_test.clj
Normal file
19
publisher/test/net/deertopia/publisher/config_test.clj
Normal file
@@ -0,0 +1,19 @@
|
||||
(ns net.deertopia.publisher.config-test
|
||||
(:require [clojure.test :as t]
|
||||
[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]))
|
||||
|
||||
(defn test-config-fixture
|
||||
"`clojure.test` fixture to run tests with the :test configuration."
|
||||
[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)))
|
||||
23
publisher/test/net/deertopia/publisher/roam-test/404.org
Normal file
23
publisher/test/net/deertopia/publisher/roam-test/404.org
Normal file
@@ -0,0 +1,23 @@
|
||||
:PROPERTIES:
|
||||
:ID: 3c60c74e-f533-43ad-89b3-563975bf80f2
|
||||
:DeertopiaVisibility: public
|
||||
:END:
|
||||
#+title: page not found
|
||||
|
||||
the page you're looking for doesn't exist, or you lack the permissions necessary to view it........
|
||||
|
||||
#+attr_doerg: :center? true :alt "A doe sitting and sobbing" :scale 1.4
|
||||
#+begin_example
|
||||
\{ / \ }/
|
||||
\/ . . \/
|
||||
.. \Y` `Y/ ..
|
||||
\ `\|~==~|/' /
|
||||
'". T T ."`
|
||||
{`^' }
|
||||
| |
|
||||
/</3 \
|
||||
|| ||
|
||||
_| || |_
|
||||
.,_) ) || ( (_,.
|
||||
|__ /_||_\ __|
|
||||
#+end_example
|
||||
@@ -0,0 +1,7 @@
|
||||
:PROPERTIES:
|
||||
:ID: 90f23e03-f746-42cb-862f-1af2d4bde3cc
|
||||
:DeertopiaVisibility: public
|
||||
:END:
|
||||
#+title: Category theory
|
||||
|
||||
*Category theory* is the mathematical study of categories and functors between them.
|
||||
@@ -1,5 +1,6 @@
|
||||
:PROPERTIES:
|
||||
:ID: ebc5ea84-77ab-4d60-9b13-ef9160b11d1f
|
||||
:DeertopiaVisibility: public
|
||||
:END:
|
||||
#+title: deertopia.net!!!!!!!!
|
||||
|
||||
|
||||
22
publisher/test/net/deertopia/publisher/roam-test/monoepi.org
Normal file
22
publisher/test/net/deertopia/publisher/roam-test/monoepi.org
Normal file
@@ -0,0 +1,22 @@
|
||||
:PROPERTIES:
|
||||
:ID: 897bfc9d-94ce-4c58-8d21-93f13372b17b
|
||||
:END:
|
||||
#+title: Monomorphisms and epimorphisms
|
||||
|
||||
In [[id:90f23e03-f746-42cb-862f-1af2d4bde3cc][category theory]], *monomorphisms* and *epimorphisms* are types of cancellative morphisms generalising injective and surjective functions, respectively.[fn:1]
|
||||
|
||||
\begin{tikzcd}
|
||||
% https://q.uiver.app/#q=WzAsNixbMCwwLCJYIl0sWzEsMCwiWSJdLFsyLDAsIloiXSxbMSwxLCJZIl0sWzIsMSwiWiJdLFswLDEsIlgiXSxbMCwxLCJnXzEiLDAseyJvZmZzZXQiOi0yfV0sWzAsMSwiZ18yIiwyLHsib2Zmc2V0IjoyfV0sWzEsMiwiZiIsMl0sWzMsNCwiZ18xIiwwLHsib2Zmc2V0IjotMn1dLFszLDQsImdfMiIsMix7Im9mZnNldCI6Mn1dLFs1LDMsImYiLDJdXQ==
|
||||
X & Y & Z \\
|
||||
X & Y & Z
|
||||
\arrow["{g_1}", shift left=2, from=1-1, to=1-2]
|
||||
\arrow["{g_2}"', shift right=2, from=1-1, to=1-2]
|
||||
\arrow["f"', from=1-2, to=1-3]
|
||||
\arrow["f"', from=2-1, to=2-2]
|
||||
\arrow["{g_1}", shift left=2, from=2-2, to=2-3]
|
||||
\arrow["{g_2}"', shift right=2, from=2-2, to=2-3]
|
||||
\end{tikzcd}
|
||||
|
||||
* Footnotes
|
||||
|
||||
[fn:1] blahahahahah blah blah
|
||||
64
publisher/test/net/deertopia/publisher/roam_test.clj
Normal file
64
publisher/test/net/deertopia/publisher/roam_test.clj
Normal file
@@ -0,0 +1,64 @@
|
||||
(ns net.deertopia.publisher.roam-test
|
||||
(:require [net.deertopia.publisher.roam :as sut]
|
||||
[clojure.test :as t]
|
||||
[clojure.java.io :as io]
|
||||
[net.deertopia.publisher.config :as publisher-cfg]
|
||||
[net.deertopia.publisher :as-alias publisher]
|
||||
[babashka.fs :as fs]
|
||||
[babashka.process :as p]
|
||||
[net.deertopia.publisher.config-test :refer [test-config-fixture]]
|
||||
[next.jdbc :as sql]
|
||||
[clojure.string :as str]
|
||||
[net.deertopia.publisher.elisp :as elisp]
|
||||
[com.rpl.specter :as sp]))
|
||||
|
||||
(def org-roam-directory
|
||||
(fs/file "test/net/deertopia/publisher/roam-test"))
|
||||
|
||||
(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)]
|
||||
(assert (->> db-file fs/canonicalize str
|
||||
(re-matches #"^/(build|tmp)/.*"))
|
||||
(format "i'm scared to delete a non-test database... %s"
|
||||
(str db-file)))
|
||||
(fs/delete-if-exists db-file)
|
||||
(org-roam-db-sync db-file)
|
||||
(f)
|
||||
(fs/delete db-file)))
|
||||
|
||||
(t/use-fixtures
|
||||
:once (t/join-fixtures [test-config-fixture test-db-fixture]))
|
||||
|
||||
|
||||
|
||||
(t/deftest all-nodes-exist
|
||||
(let [known-node-files (->> (fs/list-dir org-roam-directory)
|
||||
(map (comp str fs/canonicalize))
|
||||
(into #{}))
|
||||
database-nodes
|
||||
(->> (sql/execute!
|
||||
(sut/ds) ["select file, id from nodes"])
|
||||
(map (fn [x]
|
||||
{:file (-> x :nodes/file elisp/read-string)
|
||||
:id (-> x :nodes/id elisp/read-string parse-uuid)}))
|
||||
(into #{}))]
|
||||
(t/testing "database has a node for each file?"
|
||||
(t/is (= known-node-files (sp/transform
|
||||
[sp/ALL]
|
||||
#(:file %)
|
||||
database-nodes))))
|
||||
(t/testing "each uuid exists?"
|
||||
(t/is (every? (comp sut/uuid-exists? :id)
|
||||
database-nodes)))))
|
||||
@@ -8,44 +8,12 @@
|
||||
[net.deertopia.doerg :as-alias doerg]
|
||||
[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*
|
||||
(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)))
|
||||
|
||||
(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)))
|
||||
[clojure.java.io :as io]
|
||||
[net.deertopia.publisher.roam-test :refer [test-db-fixture]]
|
||||
[net.deertopia.publisher.config-test :refer [test-config-fixture]]))
|
||||
|
||||
(t/use-fixtures
|
||||
:once (t/join-fixtures [config-fixture test-db-fixture]))
|
||||
:once (t/join-fixtures [test-config-fixture test-db-fixture]))
|
||||
|
||||
(defn with-server [f]
|
||||
(let [was-already-running? (= :running (sut/status))]
|
||||
@@ -67,13 +35,11 @@
|
||||
(with-server
|
||||
(fn []
|
||||
(t/is (= :running (sut/status)))
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(t/is (->> (format "http://localhost:%d"
|
||||
(::publisher/port publisher-cfg/*cfg*))
|
||||
(::publisher/port publisher-cfg/*cfg*))
|
||||
slurp
|
||||
string?)))))
|
||||
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(t/deftest get-nonexistent-node
|
||||
(let [slug "3Lxvxnb0QrivoU3DX-l_5w"]
|
||||
(assert (nil? (roam/make-node slug)))
|
||||
@@ -81,7 +47,6 @@
|
||||
(-> (str "/n/" slug)
|
||||
get-sut :status)))))
|
||||
|
||||
;; 테스트 데이터베이스를 아직 안 준비한다.
|
||||
(t/deftest get-homepage
|
||||
(let [resp (-> (str "/n/" sut/homepage-slug)
|
||||
get-sut)]
|
||||
|
||||
Reference in New Issue
Block a user