2010-12-30 20:40:50 +00:00
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
require './test/replica_sets/rs_test_helper'
|
|
|
|
|
|
|
|
# NOTE: This test expects a replica set of three nodes to be running on RS.host,
|
|
|
|
# on ports TEST_PORT, RS.ports[1], and TEST + 2.
|
|
|
|
class ConnectionStringTest < Test::Unit::TestCase
|
|
|
|
include Mongo
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
RS.restart_killed_nodes
|
2011-08-25 15:27:58 +00:00
|
|
|
@conn.close if @conn
|
2010-12-30 20:40:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_connect_with_connection_string
|
|
|
|
@conn = Connection.from_uri("mongodb://#{RS.host}:#{RS.ports[0]},#{RS.host}:#{RS.ports[1]}?replicaset=#{RS.name}")
|
|
|
|
assert @conn.is_a?(ReplSetConnection)
|
|
|
|
assert @conn.connected?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_connect_with_full_connection_string
|
|
|
|
@conn = Connection.from_uri("mongodb://#{RS.host}:#{RS.ports[0]},#{RS.host}:#{RS.ports[1]}?replicaset=#{RS.name};safe=true;w=2;fsync=true;slaveok=true")
|
|
|
|
assert @conn.is_a?(ReplSetConnection)
|
|
|
|
assert @conn.connected?
|
|
|
|
assert_equal 2, @conn.safe[:w]
|
|
|
|
assert @conn.safe[:fsync]
|
|
|
|
assert @conn.read_pool
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|