From 62e0fb945edb1fe58f0f9fdbffe023c464d8d269 Mon Sep 17 00:00:00 2001 From: Toby Hede Date: Wed, 15 Feb 2012 21:32:45 +1100 Subject: [PATCH] test for drop database --- src/monger/db.clj | 10 +++++++++- test/monger/test/db.clj | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/monger/db.clj b/src/monger/db.clj index 345e6fb..330d500 100644 --- a/src/monger/db.clj +++ b/src/monger/db.clj @@ -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 @@ + diff --git a/test/monger/test/db.clj b/test/monger/test/db.clj index 300bf4c..b8f2406 100644 --- a/test/monger/test/db.clj +++ b/test/monger/test/db.clj @@ -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))) + ) +) + +