From 13135c10dd5dc690fb0a0bcd64e62ad125df7aad Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Sat, 18 Feb 2012 15:59:33 +0400 Subject: [PATCH] Make sure that tests that perform authentication and drop databases do not affect authentication tests Fixes the build. --- test/monger/test/authentication.clj | 2 +- test/monger/test/db.clj | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/test/monger/test/authentication.clj b/test/monger/test/authentication.clj index 002eed7..1813038 100644 --- a/test/monger/test/authentication.clj +++ b/test/monger/test/authentication.clj @@ -1,5 +1,5 @@ (ns monger.test.authentication - (:require [monger core util] + (:require [monger core util db] [monger.test.helper :as helper]) (:use [clojure.test])) diff --git a/test/monger/test/db.clj b/test/monger/test/db.clj index 8084a02..c03b728 100644 --- a/test/monger/test/db.clj +++ b/test/monger/test/db.clj @@ -11,19 +11,24 @@ (deftest test-add-user (let [username "clojurewerkz/monger!" - pwd (.toCharArray "monger!")] - (monger.db/add-user username pwd) - (is (monger.core/authenticate "monger-test" username pwd)))) + pwd (.toCharArray "monger!") + db-name "monger-test4"] + ;; use a secondary database here. MK. + (monger.core/with-db (monger.core/get-db db-name) + (monger.db/add-user username pwd) + (is (monger.core/authenticate db-name username pwd))))) (deftest test-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))))) + ;; drop a secondary database here. MK. + (monger.core/with-db (monger.core/get-db "monger-test3") + (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)))))) (deftest test-get-collection-names