Merge branch 'chrisbroome-more-meaningful-uri-exception'
This commit is contained in:
commit
85c7b84d13
4 changed files with 11 additions and 6 deletions
|
|
@ -1,8 +1,8 @@
|
|||
language: clojure
|
||||
sudo: required
|
||||
lein: lein
|
||||
dist: xenial
|
||||
before_script:
|
||||
- ./bin/ci/install_mongodb.sh
|
||||
- mongod --version
|
||||
- ./bin/ci/before_script.sh
|
||||
script: lein do clean, javac, test
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
# MongoDB seems to need some time to boot first. MK.
|
||||
sleep 5
|
||||
sleep 15
|
||||
|
||||
# MongoDB Java driver won't run authentication twice on the same DB instance,
|
||||
# so we need to use multiple DBs.
|
||||
|
|
|
|||
|
|
@ -233,10 +233,11 @@
|
|||
Commonly used for PaaS-based applications, for example, running on Heroku.
|
||||
If username and password are provided, performs authentication."
|
||||
[^String uri-string]
|
||||
(let [uri (MongoClientURI. uri-string)
|
||||
conn (MongoClient. uri)
|
||||
db (.getDB conn (.getDatabase uri))]
|
||||
{:conn conn :db db}))
|
||||
(let [uri (MongoClientURI. uri-string)
|
||||
conn (MongoClient. uri)]
|
||||
(if-let [dbName (.getDatabase uri)]
|
||||
{:conn conn :db (.getDB conn dbName)}
|
||||
(throw (IllegalArgumentException. "No database name specified in URI. Monger requires a database to be explicitly configured.")))))
|
||||
|
||||
(defn ^com.mongodb.CommandResult command
|
||||
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
||||
|
|
|
|||
|
|
@ -70,3 +70,7 @@
|
|||
:cursor-finalizer-enabled true
|
||||
:required-replica-set-name "rs"}]
|
||||
(is (instance? com.mongodb.MongoClientOptions$Builder (mg/mongo-options-builder opts)))))
|
||||
|
||||
(deftest connect-to-uri-without-db-name
|
||||
(let [uri "mongodb://localhost:27017"]
|
||||
(is (thrown? IllegalArgumentException (mg/connect-via-uri uri)))))
|
||||
|
|
|
|||
Loading…
Reference in a new issue