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

Stricter casting of connection pool size

This commit is contained in:
Nic Cavigliano 2018-10-05 15:02:04 -07:00 committed by Mike Perham
parent 738b62506f
commit ad396034ad
2 changed files with 10 additions and 1 deletions

View file

@ -46,7 +46,7 @@ class ConnectionPool
options = DEFAULTS.merge(options) options = DEFAULTS.merge(options)
@size = options.fetch(:size).to_i @size = Integer(options.fetch(:size))
@timeout = options.fetch(:timeout) @timeout = options.fetch(:timeout)
@available = TimedStack.new(@size, &block) @available = TimedStack.new(@size, &block)

View file

@ -130,6 +130,15 @@ class TestConnectionPool < Minitest::Test
assert_equal 1, pool.available assert_equal 1, pool.available
end end
def test_invalid_size
assert_raises ArgumentError, TypeError do
ConnectionPool.new(timeout: 0, size: nil) { Object.new }
end
assert_raises ArgumentError, TypeError do
ConnectionPool.new(timeout: 0, size: '') { Object.new }
end
end
def test_checkout_ignores_timeout def test_checkout_ignores_timeout
skip("Thread.handle_interrupt not available") unless Thread.respond_to?(:handle_interrupt) skip("Thread.handle_interrupt not available") unless Thread.respond_to?(:handle_interrupt)