diff --git a/bb.edn b/bb.edn index 91c2e463..79a16c63 100644 --- a/bb.edn +++ b/bb.edn @@ -14,3 +14,9 @@ [elin.test-helper]) ;; :task (elin.t.nrepl/-main) :task (exec 'elin.task.nrepl/-main)} + test {:extra-paths ["test"] + :extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}} + :task (exec 'cognitect.test-runner.api/test) + :exec-args {:dirs ["test"]} + :org.babashka/cli {:coerce {:nses [:symbol] + :vars [:symbol]}}}}} diff --git a/test/elin/test_helper.clj b/test/elin/test_helper.clj new file mode 100644 index 00000000..55c80c7d --- /dev/null +++ b/test/elin/test_helper.clj @@ -0,0 +1,7 @@ +(ns elin.test-helper + (:require + [malli.dev.pretty :as m.d.pretty] + [malli.instrument :as m.inst])) + +(m.inst/instrument! + {:report (m.d.pretty/reporter)}) diff --git a/test/elin/util/file_test.clj b/test/elin/util/file_test.clj new file mode 100644 index 00000000..c0dfd49c --- /dev/null +++ b/test/elin/util/file_test.clj @@ -0,0 +1,22 @@ +(ns elin.util.file-test + (:require + [clojure.string :as str] + [clojure.test :as t] + [elin.test-helper] + [elin.util.file :as sut])) + +(t/deftest find-file-in-parent-directories-test + (t/testing "README" + (t/is (= "= vim-elin" + (-> (sut/find-file-in-parent-directories "README.adoc") + (slurp) + (str/split-lines) + (first)))) + (t/is (= "= vim-elin" + (-> (sut/find-file-in-parent-directories "./src" "README.adoc") + (slurp) + (str/split-lines) + (first))))) + + (t/testing "Not found" + (t/is (nil? (sut/find-file-in-parent-directories (str "non-existing" (random-uuid))))))) diff --git a/test/elin/util/id_test.clj b/test/elin/util/id_test.clj new file mode 100644 index 00000000..01f2b914 --- /dev/null +++ b/test/elin/util/id_test.clj @@ -0,0 +1,8 @@ +(ns elin.util.id-test + (:require + [clojure.test :as t] + [elin.test-helper] + [elin.util.id :as sut])) + +(t/deftest next-id-test + (t/is (apply not= (repeatedly 100 #(sut/next-id)))))