test
This commit is contained in:
parent
612edd6fc9
commit
f9f6fa8621
1 changed files with 20 additions and 10 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
[babashka.fs :as fs]
|
[babashka.fs :as fs]
|
||||||
[babashka.test-utils :as test-utils]
|
[babashka.test-utils :as test-utils]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[clojure.test :as test :refer [deftest is]]))
|
[clojure.test :as test :refer [deftest is testing]]))
|
||||||
|
|
||||||
(defn bb [& args]
|
(defn bb [& args]
|
||||||
(edn/read-string
|
(edn/read-string
|
||||||
|
|
@ -35,15 +35,25 @@
|
||||||
(is (not (fs/exists? temp-file))))))
|
(is (not (fs/exists? temp-file))))))
|
||||||
|
|
||||||
(deftest do-task-test
|
(deftest do-task-test
|
||||||
(let [temp-dir (fs/create-temp-dir)
|
(testing ":and-do"
|
||||||
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))]
|
(let [temp-dir (fs/create-temp-dir)
|
||||||
(with-config {:tasks {:clean {:task/type :shell
|
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))]
|
||||||
:args ["rm" (str temp-file)]}
|
(with-config {:tasks {:clean {:task/type :shell
|
||||||
|
:args ["rm" (str temp-file)]}
|
||||||
|
:sum {:task/type :babashka
|
||||||
|
:args ["-e" "(+ 1 2 3)"]}
|
||||||
|
:all {:task/type :babashka
|
||||||
|
:args [:do :clean :and-do :sum]}}}
|
||||||
|
(is (fs/exists? temp-file))
|
||||||
|
(let [res (bb :all)]
|
||||||
|
(is (= 6 res)))
|
||||||
|
(is (not (fs/exists? temp-file))))))
|
||||||
|
(testing ":or-do"
|
||||||
|
(with-config {:tasks {:div-by-zero {:task/type :babashka
|
||||||
|
:args ["-e" "(/ 1 0)"]}
|
||||||
:sum {:task/type :babashka
|
:sum {:task/type :babashka
|
||||||
:args ["-e" "(+ 1 2 3)"]}
|
:args ["-e" "(+ 1 2 3)"]}
|
||||||
:all {:task/type :babashka
|
:all {:task/type :babashka
|
||||||
:args [:do :clean :and-do :sum]}}}
|
:args [:do :div-by-zero :and-do :sum]}}}
|
||||||
(is (fs/exists? temp-file))
|
(is (thrown-with-msg? Exception #"Divide"
|
||||||
(let [res (bb :all)]
|
(bb :all))))))
|
||||||
(is (= 6 res)))
|
|
||||||
(is (not (fs/exists? temp-file))))))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue