From 0ae757c69b75ef68fb8473f64f40563d3ae65d65 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Wed, 7 Mar 2012 12:38:04 -0500 Subject: [PATCH] RUBY-416 unit test stub fix --- lib/mongo/util/pool.rb | 2 +- test/pool_test.rb | 2 +- test/test_helper.rb | 1 - test/unit/read_test.rb | 2 ++ 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/mongo/util/pool.rb b/lib/mongo/util/pool.rb index 9e0b4ae..87f7c8b 100644 --- a/lib/mongo/util/pool.rb +++ b/lib/mongo/util/pool.rb @@ -19,7 +19,7 @@ module Mongo class Pool PING_ATTEMPTS = 6 MAX_PING_TIME = 1_000_000 - PRUNE_INTERVAL = 10000 + PRUNE_INTERVAL = 10_000 attr_accessor :host, :port, :address, :size, :timeout, :safe, :checked_out, :connection diff --git a/test/pool_test.rb b/test/pool_test.rb index 3428517..0a5830d 100644 --- a/test/pool_test.rb +++ b/test/pool_test.rb @@ -48,7 +48,7 @@ class PoolTest < Test::Unit::TestCase assert_equal 10, @pool.instance_variable_get(:@threads_to_sockets).size # Thread-socket pool - 1000.times do + 10000.times do @pool.checkin(@pool.checkout) end diff --git a/test/test_helper.rb b/test/test_helper.rb index cf63c20..bfd0acb 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -84,7 +84,6 @@ class Test::Unit::TestCase socket.stubs(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) socket.stubs(:close) socket.stubs(:closed?) - socket.stubs(:pool) socket end diff --git a/test/unit/read_test.rb b/test/unit/read_test.rb index 643fa5c..5322186 100644 --- a/test/unit/read_test.rb +++ b/test/unit/read_test.rb @@ -76,6 +76,7 @@ class ReadTest < Test::Unit::TestCase read_pool = stub(:checkin => true) @con.stubs(:read_pool).returns(read_pool) primary_pool = stub(:checkin => true) + sock.stubs(:pool).returns(primary_pool) @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| @@ -89,6 +90,7 @@ class ReadTest < Test::Unit::TestCase @cursor = @col.find({:a => 1}, :read => :primary) sock = new_mock_socket primary_pool = stub(:checkin => true) + sock.stubs(:pool).returns(primary_pool) @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|