Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for backing out reserved issue with tx/no-tx #133

Merged
merged 1 commit into from
Jul 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- :disable-transaction
DROP TABLE quux2;
--;;
DROP TABLE quux3;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- :disable-transaction

CREATE TABLE
quux2
(id bigint,
name varchar(255));

--;;
THIS IS MOST DEFINITELY NOT VALID SQL;

--;;

CREATE TABLE
quux3
(id bigint,
name varchar(255));
18 changes: 13 additions & 5 deletions test/migratus/test/database.clj
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,26 @@
(= java.sql.Timestamp))
from-db)))))


(deftest test-backing-out-bad-migration
(log/debug "running backout tests")
(let [{:keys [db migration-table-name] :as test-config} (assoc config :migration-dir "migrations-intentionally-broken")]
(defn- test-backing-out* [test-config]
(let [{:keys [db migration-table-name]} test-config]
(testing "should fail")
(is (thrown? Throwable (core/migrate test-config)))
(testing "first statement in migration was backed out because second one failed")
(is (not (test-sql/verify-table-exists? test-config "quux2")))
(testing "third statement in migration was backed out because second one failed")
(is (not (test-sql/verify-table-exists? test-config "quux3")))
(testing "migration was not applied")
(is (not (complete? db migration-table-name 20120827170200)))))
(is (not (complete? db migration-table-name 20120827170200)))
(testing "table should be unreserved after migration failure")
(is (mark-reserved db migration-table-name))))

(deftest test-backing-out-bad-migration
(log/debug "running backout tests")
(test-backing-out* (assoc config :migration-dir "migrations-intentionally-broken")))

(deftest test-backing-out-bad-migration-no-tx
(log/debug "running backout tests without tx")
(test-backing-out* (assoc config :migration-dir "migrations-intentionally-broken-no-tx")))


(deftest test-no-tx-migration
Expand Down