fix breakage when running tests on non-default port. removing ability to specify connections in [port, host] ordering.

This commit is contained in:
Mike Dirolf 2009-03-02 13:37:12 -05:00
parent 27d6106376
commit a5a2e82836
3 changed files with 6 additions and 11 deletions

View File

@ -34,7 +34,7 @@ module XGen
# and :right. Each key maps to either
# * a server name, in which case port is DEFAULT_PORT
# * 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:
#
@ -127,8 +127,8 @@ module XGen
protected
# Turns an array containing an optional host name string and an
# optional port number integer into a [host, port] pair array.
# Turns an array containing a host name string and a
# port number integer into a [host, port] pair array.
def pair_val_to_connection(a)
case a
when nil
@ -138,12 +138,7 @@ module XGen
when Integer
['localhost', a]
when Array
connection = ['localhost', DEFAULT_PORT]
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
a
end
end

View File

@ -56,7 +56,7 @@ class DBTest < Test::Unit::TestCase
@@db = Mongo.new({:left => "this-should-fail", :right => [@@host, @@port]}).db('ruby-mongo-test')
assert @@db.connected?
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')
end

View File

@ -64,7 +64,7 @@ class MongoTest < Test::Unit::TestCase
assert_equal ['localhost', Mongo::DEFAULT_PORT], pair[0]
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')
assert_equal 2, pair.length
assert_equal ['bar', Mongo::DEFAULT_PORT], pair[0]