Compare commits
No commits in common. "db_from_uri" and "master" have entirely different histories.
db_from_ur
...
master
|
@ -34,7 +34,6 @@ module Mongo
|
|||
|
||||
DEFAULT_HOST = 'localhost'
|
||||
DEFAULT_PORT = 27017
|
||||
DEFAULT_DB_NAME = 'test'
|
||||
GENERIC_OPTS = [:ssl, :auths, :pool_size, :pool_timeout, :timeout, :op_timeout, :connect_timeout, :safe, :logger, :connect]
|
||||
CONNECTION_OPTS = [:slave_ok]
|
||||
|
||||
|
@ -313,13 +312,7 @@ module Mongo
|
|||
# @return [Mongo::DB]
|
||||
#
|
||||
# @core databases db-instance_method
|
||||
def db(db_name=nil, opts={})
|
||||
if !db_name && uri = ENV['MONGODB_URI']
|
||||
db_name = uri[%r{/([^/\?]+)(\?|$)}, 1]
|
||||
end
|
||||
|
||||
db_name ||= DEFAULT_DB_NAME
|
||||
|
||||
def db(db_name, opts={})
|
||||
DB.new(db_name, self, opts)
|
||||
end
|
||||
|
||||
|
|
|
@ -82,46 +82,6 @@ class TestConnection < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_db_from_uri_exists_no_options
|
||||
begin
|
||||
db_name = "_database"
|
||||
|
||||
old_mongodb_uri = ENV['MONGODB_URI']
|
||||
ENV['MONGODB_URI'] = "mongodb://#{host_port}/#{db_name}"
|
||||
con = Connection.from_uri
|
||||
db = con.db
|
||||
assert_equal db.name, db_name
|
||||
ensure
|
||||
ENV['MONGODB_URI'] = old_mongodb_uri
|
||||
end
|
||||
end
|
||||
|
||||
def test_db_from_uri_exists_options
|
||||
begin
|
||||
db_name = "_database"
|
||||
|
||||
old_mongodb_uri = ENV['MONGODB_URI']
|
||||
ENV['MONGODB_URI'] = "mongodb://#{host_port}/#{db_name}?"
|
||||
con = Connection.from_uri
|
||||
db = con.db
|
||||
assert_equal db.name, db_name
|
||||
ensure
|
||||
ENV['MONGODB_URI'] = old_mongodb_uri
|
||||
end
|
||||
end
|
||||
|
||||
def test_db_from_uri_exists_no_db_name
|
||||
begin
|
||||
old_mongodb_uri = ENV['MONGODB_URI']
|
||||
ENV['MONGODB_URI'] = "mongodb://#{host_port}/"
|
||||
con = Connection.from_uri
|
||||
db = con.db
|
||||
assert_equal db.name, Mongo::Connection::DEFAULT_DB_NAME
|
||||
ensure
|
||||
ENV['MONGODB_URI'] = old_mongodb_uri
|
||||
end
|
||||
end
|
||||
|
||||
def test_server_version
|
||||
assert_match(/\d\.\d+(\.\d+)?/, @conn.server_version.to_s)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue