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}
(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
(let [temp-dir (fs/create-temp-dir)
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))
bb-edn-file (fs/file temp-dir "bb.edn")
bb-edn `{:tasks {:clean {:task/type :shell
:args ["rm" ~(str temp-file)]}}}]
(spit bb-edn-file bb-edn)
(is (fs/exists? temp-file))
(binding [test-utils/*bb-edn-path* (str bb-edn-file)]
(bb :clean))
(is (not (fs/exists? temp-file)))))
temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))]
(with-config {:tasks {:clean {:task/type :shell
:args ["rm" (str temp-file)]}}}
(is (fs/exists? temp-file))
(bb :clean)
(is (not (fs/exists? temp-file))))))