fixed connection uri bug (Sunny Hirai)
This commit is contained in:
parent
59b034dddc
commit
67a56b64eb
|
@ -522,11 +522,11 @@ module Mongo
|
||||||
port = port.to_i
|
port = port.to_i
|
||||||
db = matches[8]
|
db = matches[8]
|
||||||
|
|
||||||
if (uname || pwd || db) && !(uname && pwd && db)
|
if uname && pwd && db
|
||||||
|
add_auth(db, uname, pwd)
|
||||||
|
elsif uname || pwd || db
|
||||||
raise MongoArgumentError, "MongoDB URI must include all three of username, password, " +
|
raise MongoArgumentError, "MongoDB URI must include all three of username, password, " +
|
||||||
"and db if any one of these is specified."
|
"and db if any one of these is specified."
|
||||||
else
|
|
||||||
add_auth(db, uname, pwd)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
nodes << [host, port]
|
nodes << [host, port]
|
||||||
|
|
|
@ -24,6 +24,12 @@ class TestConnection < Test::Unit::TestCase
|
||||||
assert Mongo::Support.ok?(server_info)
|
assert Mongo::Support.ok?(server_info)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_connection_uri
|
||||||
|
con = Connection.from_uri("mongodb://localhost:27017")
|
||||||
|
assert_equal "localhost", con.host
|
||||||
|
assert_equal 27017, con.port
|
||||||
|
end
|
||||||
|
|
||||||
def test_server_version
|
def test_server_version
|
||||||
assert_match /\d\.\d+(\.\d+)?/, @mongo.server_version.to_s
|
assert_match /\d\.\d+(\.\d+)?/, @mongo.server_version.to_s
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue