fixed connection uri bug (Sunny Hirai)

This commit is contained in:
Kyle Banker 2010-06-12 10:11:29 -04:00
parent 59b034dddc
commit 67a56b64eb
2 changed files with 9 additions and 3 deletions

View File

@ -522,11 +522,11 @@ module Mongo
port = port.to_i
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, " +
"and db if any one of these is specified."
else
add_auth(db, uname, pwd)
end
nodes << [host, port]

View File

@ -24,6 +24,12 @@ class TestConnection < Test::Unit::TestCase
assert Mongo::Support.ok?(server_info)
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
assert_match /\d\.\d+(\.\d+)?/, @mongo.server_version.to_s
end