Merge pull request #12 from tobyhede/63870b1136e63865ba349faa159d473b3cab79a7

new core/get-db-names
This commit is contained in:
Michael Klishin 2012-02-20 04:00:40 -08:00
commit 7348ca9f2e
2 changed files with 16 additions and 0 deletions

View file

@ -53,6 +53,15 @@
(Mongo. ^String host ^Long port))) (Mongo. ^String host ^Long port)))
(defn ^DB get-db-names
"Gets a list of all database names present on the server"
([]
(list (.getDatabaseNames *mongodb-connection*)))
([^Mongo connection]
(list (.getDatabaseNames connection))))
(defn ^DB get-db (defn ^DB get-db
"Get database reference by name. "Get database reference by name.

View file

@ -28,6 +28,13 @@
(is (instance? com.mongodb.DB db)))) (is (instance? com.mongodb.DB db))))
(deftest test-get-db-names
(let [dbs (monger.core/get-db-names)]
(is (not (empty? dbs)))
(is (some #{"monger-test"} dbs))
)
)
;; (deftest get-database-with-valid-credentials ;; (deftest get-database-with-valid-credentials
;; (let [connection (monger.core/connect) ;; (let [connection (monger.core/connect)
;; db (monger.core/get-db connection "monger-test" "monger" "test_password")] ;; db (monger.core/get-db connection "monger-test" "monger" "test_password")]