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:
parent
738b62506f
commit
ad396034ad
2 changed files with 10 additions and 1 deletions
|
@ -46,7 +46,7 @@ class ConnectionPool
|
|||
|
||||
options = DEFAULTS.merge(options)
|
||||
|
||||
@size = options.fetch(:size).to_i
|
||||
@size = Integer(options.fetch(:size))
|
||||
@timeout = options.fetch(:timeout)
|
||||
|
||||
@available = TimedStack.new(@size, &block)
|
||||
|
|
|
@ -130,6 +130,15 @@ class TestConnectionPool < Minitest::Test
|
|||
assert_equal 1, pool.available
|
||||
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
|
||||
skip("Thread.handle_interrupt not available") unless Thread.respond_to?(:handle_interrupt)
|
||||
|
||||
|
|
Loading…
Reference in a new issue