fix breakage when running tests on non-default port. removing ability to specify connections in [port, host] ordering.
This commit is contained in:
parent
27d6106376
commit
a5a2e82836
|
@ -34,7 +34,7 @@ module XGen
|
||||||
# and :right. Each key maps to either
|
# and :right. Each key maps to either
|
||||||
# * a server name, in which case port is DEFAULT_PORT
|
# * a server name, in which case port is DEFAULT_PORT
|
||||||
# * a port number, in which case server is "localhost"
|
# * a port number, in which case server is "localhost"
|
||||||
# * an array containing a server name and a port number in either order
|
# * an array containing a server name and a port number in that order
|
||||||
#
|
#
|
||||||
# +options+ are passed on to each DB instance:
|
# +options+ are passed on to each DB instance:
|
||||||
#
|
#
|
||||||
|
@ -127,8 +127,8 @@ module XGen
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# Turns an array containing an optional host name string and an
|
# Turns an array containing a host name string and a
|
||||||
# optional port number integer into a [host, port] pair array.
|
# port number integer into a [host, port] pair array.
|
||||||
def pair_val_to_connection(a)
|
def pair_val_to_connection(a)
|
||||||
case a
|
case a
|
||||||
when nil
|
when nil
|
||||||
|
@ -138,12 +138,7 @@ module XGen
|
||||||
when Integer
|
when Integer
|
||||||
['localhost', a]
|
['localhost', a]
|
||||||
when Array
|
when Array
|
||||||
connection = ['localhost', DEFAULT_PORT]
|
a
|
||||||
connection[0] = a[0] if a[0].kind_of?(String)
|
|
||||||
connection[0] = a[1] if a[1].kind_of?(String)
|
|
||||||
connection[1] = a[0] if a[0].kind_of?(Integer)
|
|
||||||
connection[1] = a[1] if a[1].kind_of?(Integer)
|
|
||||||
connection
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class DBTest < Test::Unit::TestCase
|
||||||
@@db = Mongo.new({:left => "this-should-fail", :right => [@@host, @@port]}).db('ruby-mongo-test')
|
@@db = Mongo.new({:left => "this-should-fail", :right => [@@host, @@port]}).db('ruby-mongo-test')
|
||||||
assert @@db.connected?
|
assert @@db.connected?
|
||||||
ensure
|
ensure
|
||||||
@@db = Mongo.new(@@host, @@port) unless @@db.connected?
|
@@db = Mongo.new(@@host, @@port).db('ruby-mongo-test') unless @@db.connected?
|
||||||
@@users = @@db.collection('system.users')
|
@@users = @@db.collection('system.users')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class MongoTest < Test::Unit::TestCase
|
||||||
assert_equal ['localhost', Mongo::DEFAULT_PORT], pair[0]
|
assert_equal ['localhost', Mongo::DEFAULT_PORT], pair[0]
|
||||||
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[1]
|
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[1]
|
||||||
|
|
||||||
db = Mongo.new({:right => [123, 'foo'], :left => 'bar'})
|
db = Mongo.new({:right => ['foo', 123], :left => 'bar'})
|
||||||
pair = db.instance_variable_get('@pair')
|
pair = db.instance_variable_get('@pair')
|
||||||
assert_equal 2, pair.length
|
assert_equal 2, pair.length
|
||||||
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[0]
|
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[0]
|
||||||
|
|
Loading…
Reference in New Issue