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
|
language: clojure
|
||||||
sudo: required
|
sudo: required
|
||||||
lein: lein
|
lein: lein
|
||||||
|
dist: xenial
|
||||||
before_script:
|
before_script:
|
||||||
- ./bin/ci/install_mongodb.sh
|
|
||||||
- mongod --version
|
- mongod --version
|
||||||
- ./bin/ci/before_script.sh
|
- ./bin/ci/before_script.sh
|
||||||
script: lein do clean, javac, test
|
script: lein do clean, javac, test
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# MongoDB seems to need some time to boot first. MK.
|
# 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,
|
# MongoDB Java driver won't run authentication twice on the same DB instance,
|
||||||
# so we need to use multiple DBs.
|
# so we need to use multiple DBs.
|
||||||
|
|
|
||||||
|
|
@ -233,10 +233,11 @@
|
||||||
Commonly used for PaaS-based applications, for example, running on Heroku.
|
Commonly used for PaaS-based applications, for example, running on Heroku.
|
||||||
If username and password are provided, performs authentication."
|
If username and password are provided, performs authentication."
|
||||||
[^String uri-string]
|
[^String uri-string]
|
||||||
(let [uri (MongoClientURI. uri-string)
|
(let [uri (MongoClientURI. uri-string)
|
||||||
conn (MongoClient. uri)
|
conn (MongoClient. uri)]
|
||||||
db (.getDB conn (.getDatabase uri))]
|
(if-let [dbName (.getDatabase uri)]
|
||||||
{:conn conn :db db}))
|
{: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
|
(defn ^com.mongodb.CommandResult command
|
||||||
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
||||||
|
|
|
||||||
|
|
@ -70,3 +70,7 @@
|
||||||
:cursor-finalizer-enabled true
|
:cursor-finalizer-enabled true
|
||||||
:required-replica-set-name "rs"}]
|
:required-replica-set-name "rs"}]
|
||||||
(is (instance? com.mongodb.MongoClientOptions$Builder (mg/mongo-options-builder opts)))))
|
(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