Make sure that tests that perform authentication and drop databases do not affect authentication tests
Fixes the build.
This commit is contained in:
parent
e29655a7fd
commit
13135c10dd
2 changed files with 16 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
(ns monger.test.authentication
|
(ns monger.test.authentication
|
||||||
(:require [monger core util]
|
(:require [monger core util db]
|
||||||
[monger.test.helper :as helper])
|
[monger.test.helper :as helper])
|
||||||
(:use [clojure.test]))
|
(:use [clojure.test]))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,19 +11,24 @@
|
||||||
|
|
||||||
(deftest test-add-user
|
(deftest test-add-user
|
||||||
(let [username "clojurewerkz/monger!"
|
(let [username "clojurewerkz/monger!"
|
||||||
pwd (.toCharArray "monger!")]
|
pwd (.toCharArray "monger!")
|
||||||
(monger.db/add-user username pwd)
|
db-name "monger-test4"]
|
||||||
(is (monger.core/authenticate "monger-test" username pwd))))
|
;; 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
|
(deftest test-drop-database
|
||||||
(let [collection "test"
|
;; drop a secondary database here. MK.
|
||||||
_ (mgcol/insert collection { :name "Clojure" })
|
(monger.core/with-db (monger.core/get-db "monger-test3")
|
||||||
check (mgcol/count collection)
|
(let [collection "test"
|
||||||
_ (monger.db/drop-db)]
|
_ (mgcol/insert collection { :name "Clojure" })
|
||||||
(is (= 1 check))
|
check (mgcol/count collection)
|
||||||
(is (not (mgcol/exists? collection)))
|
_ (monger.db/drop-db)]
|
||||||
(is (= 0 (mgcol/count collection)))))
|
(is (= 1 check))
|
||||||
|
(is (not (mgcol/exists? collection)))
|
||||||
|
(is (= 0 (mgcol/count collection))))))
|
||||||
|
|
||||||
|
|
||||||
(deftest test-get-collection-names
|
(deftest test-get-collection-names
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue