1
0
Fork 0
mirror of https://github.com/mperham/connection_pool synced 2023-03-27 23:22:21 -04:00

Verify checkout ignores timeout

This commit is contained in:
Mike Perham 2015-04-10 12:00:29 -07:00
parent 238a02d6e3
commit 4d03ff625a

View file

@ -120,7 +120,27 @@ class TestConnectionPool < Minitest::Test
end
end
end
assert_equal 1, pool.instance_variable_get(:@available).instance_variable_get(:@que).size
end
def test_checkout_ignores_timeout
pool = ConnectionPool.new(:timeout => 0, :size => 1) { Object.new }
def pool.checkout(options)
obj = super
sleep 0.015
obj
end
did_something = false
assert_raises Timeout::Error do
Timeout.timeout(0.01) do
pool.with do |obj|
did_something = true
assert_equal 0, pool.instance_variable_get(:@available).instance_variable_get(:@que).size
end
end
end
assert did_something
assert_equal 1, pool.instance_variable_get(:@available).instance_variable_get(:@que).size
end