Cosmetics
This commit is contained in:
parent
1494cc5ad4
commit
e29655a7fd
2 changed files with 14 additions and 27 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
(defn add-user
|
(defn add-user
|
||||||
"Adds a new user for this db"
|
"Adds a new user for this db"
|
||||||
([^String username, ^chars password]
|
([^String username, ^chars password]
|
||||||
(.addUser ^DB monger.core/*mongodb-database* username password))
|
(.addUser ^DB monger.core/*mongodb-database* username password))
|
||||||
([^DB database ^String username, ^chars password]
|
([^DB database ^String username, ^chars password]
|
||||||
(.addUser ^DB database username password)))
|
(.addUser ^DB database username password)))
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
(defn drop-db
|
(defn drop-db
|
||||||
"Drops the currently set database (via core/set-db) or the specified database."
|
"Drops the currently set database (via core/set-db) or the specified database."
|
||||||
([]
|
([]
|
||||||
(.dropDatabase ^DB monger.core/*mongodb-database*))
|
(.dropDatabase ^DB monger.core/*mongodb-database*))
|
||||||
([^DB database]
|
([^DB database]
|
||||||
(.dropDatabase ^DB database)))
|
(.dropDatabase ^DB database)))
|
||||||
|
|
@ -32,12 +32,7 @@
|
||||||
|
|
||||||
(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*)))
|
(set (.getCollectionNames ^DB monger.core/*mongodb-database*)))
|
||||||
([^DB database]
|
([^DB database]
|
||||||
(into #{} (.getCollectionNames ^DB database)))
|
(set (.getCollectionNames ^DB database))))
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
(ns monger.test.db
|
(ns monger.test.db
|
||||||
(:require [monger core db]
|
(:require [monger core db]
|
||||||
[monger.test.helper :as helper]
|
[monger.test.helper :as helper]
|
||||||
[monger.collection :as mgcol])
|
[monger.collection :as mgcol])
|
||||||
(:import (com.mongodb Mongo DB))
|
(:import (com.mongodb Mongo DB))
|
||||||
(:use [clojure.test]))
|
(:use [clojure.test]))
|
||||||
|
|
@ -9,34 +9,26 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(deftest 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)
|
(monger.db/add-user username pwd)
|
||||||
(is (monger.core/authenticate "monger-test" username pwd))))
|
(is (monger.core/authenticate "monger-test" username pwd))))
|
||||||
|
|
||||||
|
|
||||||
(deftest drop-database
|
(deftest test-drop-database
|
||||||
(let [collection "test"
|
(let [collection "test"
|
||||||
_ (mgcol/insert collection { :name "Clojure" })
|
_ (mgcol/insert collection { :name "Clojure" })
|
||||||
check (mgcol/count collection)
|
check (mgcol/count collection)
|
||||||
_ (monger.db/drop-db)
|
_ (monger.db/drop-db)]
|
||||||
]
|
|
||||||
(is (= 1 check))
|
(is (= 1 check))
|
||||||
(is (not (mgcol/exists? collection)))
|
(is (not (mgcol/exists? collection)))
|
||||||
(is (= 0 (mgcol/count collection)))
|
(is (= 0 (mgcol/count collection)))))
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(deftest get-collection-names
|
(deftest test-get-collection-names
|
||||||
(mgcol/insert "test-1" { :name "Clojure" })
|
(mgcol/insert "test-1" { :name "Clojure" })
|
||||||
(mgcol/insert "test-2" { :name "Clojure" })
|
(mgcol/insert "test-2" { :name "Clojure" })
|
||||||
(let [collections (monger.db/get-collection-names)]
|
(let [collections (monger.db/get-collection-names)]
|
||||||
(is (.contains collections "test-1"))
|
(is (.contains collections "test-1"))
|
||||||
(is (.contains collections "test-2"))
|
(is (.contains collections "test-2"))))
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue