Fix: must return ids in creation order
This commit is contained in:
parent
a04596cdc5
commit
0179bbc046
2 changed files with 23 additions and 6 deletions
|
|
@ -24,7 +24,7 @@
|
||||||
(let [xs (with-collection migrations-collection
|
(let [xs (with-collection migrations-collection
|
||||||
(find {})
|
(find {})
|
||||||
(sort {:created_at 1}))]
|
(sort {:created_at 1}))]
|
||||||
(set (map :_id xs))))))
|
(vec (map :_id xs))))))
|
||||||
|
|
||||||
|
|
||||||
(defn flush-migrations!
|
(defn flush-migrations!
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@
|
||||||
key "1"]
|
key "1"]
|
||||||
(mc/remove db coll {})
|
(mc/remove db coll {})
|
||||||
(is (not (mc/any? db coll {:_id key})))
|
(is (not (mc/any? db coll {:_id key})))
|
||||||
(is (not (contains? (applied-migration-ids db) key)))
|
(is (not (some #{key} (applied-migration-ids db))))
|
||||||
(add-migration-id db key)
|
(add-migration-id db key)
|
||||||
(is (mc/any? db coll {:_id key}))
|
(is (mc/any? db coll {:_id key}))
|
||||||
(is (contains? (applied-migration-ids db) key))))
|
(is (some #{key} (applied-migration-ids db)))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-remove-migration-id
|
(deftest test-remove-migration-id
|
||||||
|
|
@ -35,6 +35,23 @@
|
||||||
(mc/remove db coll {})
|
(mc/remove db coll {})
|
||||||
(add-migration-id db key)
|
(add-migration-id db key)
|
||||||
(is (mc/any? db coll {:_id key}))
|
(is (mc/any? db coll {:_id key}))
|
||||||
(is (contains? (applied-migration-ids db) key))
|
(is (some #{key} (applied-migration-ids db)))
|
||||||
(remove-migration-id db key)
|
(remove-migration-id db key)
|
||||||
(is (not (contains? (applied-migration-ids db) key))))))
|
(is (not (some #{key} (applied-migration-ids db))))))
|
||||||
|
|
||||||
|
|
||||||
|
(deftest test-migrations-ordering
|
||||||
|
(let [db (mg/get-db "monger-test")
|
||||||
|
coll "meta.migrations"
|
||||||
|
all-keys [ "9" "4" "7" "1" "5" "3" "6" "2" "8"]]
|
||||||
|
(mc/remove db coll {})
|
||||||
|
|
||||||
|
(doseq [key all-keys]
|
||||||
|
(add-migration-id db key))
|
||||||
|
|
||||||
|
(doseq [key all-keys]
|
||||||
|
(is (mc/any? db coll {:_id key}))
|
||||||
|
(is (some #{key} (applied-migration-ids db))))
|
||||||
|
|
||||||
|
(testing "Applied migrations must come out in creation order"
|
||||||
|
(is (= all-keys (applied-migration-ids db)))))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue