test for drop database
This commit is contained in:
parent
300220da15
commit
62e0fb945e
2 changed files with 22 additions and 1 deletions
|
|
@ -13,9 +13,16 @@
|
||||||
(:require [monger core]))
|
(:require [monger core]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn drop-db
|
||||||
|
"Drops the specified database."
|
||||||
|
([]
|
||||||
|
(.dropDatabase ^DB monger.core/*mongodb-database*))
|
||||||
|
([^DB database]
|
||||||
|
(.dropDatabase ^DB database)))
|
||||||
|
|
||||||
|
|
||||||
(defn get-collection-names
|
(defn get-collection-names
|
||||||
"Returns a set containing the names of all collections in this database.."
|
"Returns a set containing the names of all collections in this database."
|
||||||
([]
|
([]
|
||||||
(into #{} (.getCollectionNames ^DB monger.core/*mongodb-database*)))
|
(into #{} (.getCollectionNames ^DB monger.core/*mongodb-database*)))
|
||||||
([^DB database]
|
([^DB database]
|
||||||
|
|
@ -24,3 +31,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,16 @@
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
(deftest drop-database
|
||||||
|
(let [collection "test"
|
||||||
|
_ (mgcol/insert collection { :name "Clojure" })
|
||||||
|
check (mgcol/count collection)
|
||||||
|
_ (monger.db/drop-db)
|
||||||
|
]
|
||||||
|
(is (= 1 check))
|
||||||
|
(is (not (mgcol/exists? collection)))
|
||||||
|
(is (= 0 (mgcol/count collection)))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue