Skip to content
Snippets Groups Projects
Commit a955419f authored by Cam Saul's avatar Cam Saul
Browse files

Merge branch 'master' into merge-release-0.36.x

parents c941660a c60510b0
No related merge requests found
......@@ -38,24 +38,27 @@
cols+vals)))))
(deftest dump-deletes-target-db-files-tests
(let [tmp-h2-db (str (u.files/get-path (System/getProperty "java.io.tmpdir") "mbtest_dump.h2"))
tmp-h2-db-mv (str tmp-h2-db ".mv.db")
file-contents {tmp-h2-db "Not really an H2 DB"
tmp-h2-db-mv "Not really another H2 DB"}]
;; keep setup-db!/setup-db!* from changing connection state
(with-redefs [mdb/setup-db! (constantly nil)
mdb/setup-db!* (constantly nil)]
(try
(doseq [[filename contents] file-contents]
(spit filename contents))
(dump-to-h2/dump-to-h2! tmp-h2-db)
;; test fails when the application db is anything but H2 presently
;; TODO: make this test work with postgres / mysql / mariadb
(when (= :h2 (mdb/db-type))
(let [tmp-h2-db (str (u.files/get-path (System/getProperty "java.io.tmpdir") "mbtest_dump.h2"))
tmp-h2-db-mv (str tmp-h2-db ".mv.db")
file-contents {tmp-h2-db "Not really an H2 DB"
tmp-h2-db-mv "Not really another H2 DB"}]
;; keep setup-db!/setup-db!* from changing connection state
(with-redefs [mdb/setup-db! (constantly nil)
mdb/setup-db!* (constantly nil)]
(try
(doseq [[filename contents] file-contents]
(spit filename contents))
(dump-to-h2/dump-to-h2! tmp-h2-db)
(doseq [filename (keys file-contents)]
(testing (str filename " was deleted")
(is (false? (.exists (io/file filename))))))
(doseq [filename (keys file-contents)]
(testing (str filename " was deleted")
(is (false? (.exists (io/file filename))))))
(finally
(doseq [filename (keys file-contents)
:let [file (io/file filename)]]
(when (.exists file)
(io/delete-file file))))))))
(finally
(doseq [filename (keys file-contents)
:let [file (io/file filename)]]
(when (.exists file)
(io/delete-file file)))))))))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment