Skip to content

Commit

Permalink
test: Add bb task to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jan 15, 2024
1 parent f54d6a5 commit 0e3e4de
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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]}}}}}
7 changes: 7 additions & 0 deletions test/elin/test_helper.clj
Original file line number Diff line number Diff line change
@@ -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)})
22 changes: 22 additions & 0 deletions test/elin/util/file_test.clj
Original file line number Diff line number Diff line change
@@ -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)))))))
8 changes: 8 additions & 0 deletions test/elin/util/id_test.clj
Original file line number Diff line number Diff line change
@@ -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)))))

0 comments on commit 0e3e4de

Please sign in to comment.