Test macro [skip ci]

This commit is contained in:
Michiel Borkent 2021-03-20 13:22:33 +01:00
parent a44f07a665
commit 6e4313700f

View file

@ -12,15 +12,19 @@
:eof nil} :eof nil}
(apply test-utils/bb nil (map str args)))) (apply test-utils/bb nil (map str args))))
(defmacro with-config [cfg & body]
`(let [temp-dir# (fs/create-temp-dir)
bb-edn-file# (fs/file temp-dir# "bb.edn")]
(spit bb-edn-file# ~cfg)
(binding [test-utils/*bb-edn-path* (str bb-edn-file#)]
~@body)))
(deftest foobar-test (deftest foobar-test
(let [temp-dir (fs/create-temp-dir) (let [temp-dir (fs/create-temp-dir)
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt")) temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))]
bb-edn-file (fs/file temp-dir "bb.edn") (with-config {:tasks {:clean {:task/type :shell
bb-edn `{:tasks {:clean {:task/type :shell :args ["rm" (str temp-file)]}}}
:args ["rm" ~(str temp-file)]}}}] (is (fs/exists? temp-file))
(spit bb-edn-file bb-edn) (bb :clean)
(is (fs/exists? temp-file)) (is (not (fs/exists? temp-file))))))
(binding [test-utils/*bb-edn-path* (str bb-edn-file)]
(bb :clean))
(is (not (fs/exists? temp-file)))))