minor: fix failing tests
This commit is contained in:
parent
dc4be1afc7
commit
83ac53202e
|
@ -483,13 +483,21 @@ module Mongo
|
|||
|
||||
def get_local_reader
|
||||
self.connections ||= {}
|
||||
self.connections[self.object_id] ||= {}
|
||||
if !connected? && self.connections[self.object_id]
|
||||
self.connections[self.object_id]
|
||||
else
|
||||
self.connections[self.object_id] = {}
|
||||
end
|
||||
self.connections[self.object_id][:reader] ||= checkout_reader
|
||||
end
|
||||
|
||||
def get_local_writer
|
||||
self.connections ||= {}
|
||||
self.connections[self.object_id] ||= {}
|
||||
if !connected? && self.connections[self.object_id]
|
||||
self.connections[self.object_id]
|
||||
else
|
||||
self.connections[self.object_id] = {}
|
||||
end
|
||||
self.connections[self.object_id][:writer] ||= checkout_writer
|
||||
end
|
||||
|
||||
|
|
|
@ -311,18 +311,24 @@ module Mongo
|
|||
|
||||
def get_local_reader
|
||||
self.connections ||= {}
|
||||
self.connections[self.object_id] ||= {}
|
||||
if !connected? && self.connections[self.object_id]
|
||||
self.connections[self.object_id]
|
||||
else
|
||||
self.connections[self.object_id] = {}
|
||||
end
|
||||
socket = self.connections[self.object_id][:reader] ||= checkout_reader
|
||||
@threads_to_sockets[Thread.current][:reader] = socket
|
||||
socket
|
||||
end
|
||||
|
||||
def get_local_writer
|
||||
self.connections ||= {}
|
||||
self.connections[self.object_id] ||= {}
|
||||
if !connected? && self.connections[self.object_id]
|
||||
self.connections[self.object_id]
|
||||
else
|
||||
self.connections[self.object_id] = {}
|
||||
end
|
||||
socket = self.connections[self.object_id][:writer] ||= checkout_writer
|
||||
@threads_to_sockets[Thread.current][:writer] = socket
|
||||
socket
|
||||
end
|
||||
|
||||
# Used to close, check in, or refresh sockets held
|
||||
|
|
|
@ -301,6 +301,7 @@ class TestCollection < Test::Unit::TestCase
|
|||
@conn = standard_connection
|
||||
@db = @conn[MONGO_TEST_DB]
|
||||
@test = @db['test-safe-remove']
|
||||
@test.remove
|
||||
@test.save({:a => 50})
|
||||
assert_equal 1, @test.remove({}, :safe => true)["n"]
|
||||
@test.drop
|
||||
|
@ -782,6 +783,7 @@ class TestCollection < Test::Unit::TestCase
|
|||
context "A collection with two records" do
|
||||
setup do
|
||||
@collection = @@db.collection('test-collection')
|
||||
@collection.remove
|
||||
@collection.insert({:name => "Jones"})
|
||||
@collection.insert({:name => "Smith"})
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ class CursorTest < Test::Unit::TestCase
|
|||
def test_exhaust
|
||||
if @@version >= "2.0"
|
||||
@@coll.remove
|
||||
data = "1" * 100_000
|
||||
data = "1" * 10_000
|
||||
5000.times do |n|
|
||||
@@coll.insert({:n => n, :data => data})
|
||||
end
|
||||
|
|
|
@ -12,6 +12,7 @@ class PoolManagerTest < Test::Unit::TestCase
|
|||
@connection = stub("Connection")
|
||||
@connection.stubs(:connect_timeout).returns(5000)
|
||||
@connection.stubs(:pool_size).returns(2)
|
||||
@connection.stubs(:pool_timeout).returns(100)
|
||||
@connection.stubs(:socket_class).returns(TCPSocket)
|
||||
@connection.stubs(:[]).returns(@db)
|
||||
|
||||
|
|
|
@ -74,6 +74,10 @@ class ReadTest < Test::Unit::TestCase
|
|||
@cursor = @col.find({:a => 1})
|
||||
sock = mock()
|
||||
sock.expects(:close)
|
||||
read_pool = stub(:sockets_low? => false)
|
||||
@con.stubs(:read_pool).returns(read_pool)
|
||||
primary_pool = stub(:sockets_low? => false)
|
||||
@con.stubs(:primary_pool).returns(primary_pool)
|
||||
@con.expects(:checkout_reader).returns(sock)
|
||||
@con.expects(:receive_message).with do |o, m, l, s, c, r|
|
||||
r == nil
|
||||
|
@ -86,6 +90,8 @@ class ReadTest < Test::Unit::TestCase
|
|||
@cursor = @col.find({:a => 1}, :read => :primary)
|
||||
sock = mock()
|
||||
sock.expects(:close)
|
||||
primary_pool = stub(:sockets_low? => false)
|
||||
@con.stubs(:primary_pool).returns(primary_pool)
|
||||
@con.expects(:checkout_writer).returns(sock)
|
||||
@con.expects(:receive_message).with do |o, m, l, s, c, r|
|
||||
r == nil
|
||||
|
|
Loading…
Reference in New Issue