test for drop database

This commit is contained in:
Toby Hede 2012-02-15 21:32:45 +11:00
parent 300220da15
commit 62e0fb945e
2 changed files with 22 additions and 1 deletions

View file

@ -13,9 +13,16 @@
(: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
"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*)))
([^DB database]
@ -24,3 +31,4 @@

View file

@ -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)))
)
)