mirror of
https://github.com/mperham/connection_pool
synced 2023-03-27 23:22:21 -04:00
Don't let threads die from exceptions in tests
Catch Exceptions in threads used in tests instead of letting them die from uncaught exception where a warning would be triggered in Ruby >= 2.5 with Thread.report_on_exception enabled by default.
This commit is contained in:
parent
ad396034ad
commit
306fd1b537
1 changed files with 18 additions and 14 deletions
|
@ -108,9 +108,11 @@ class TestConnectionPool < Minitest::Test
|
|||
pool = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
|
||||
|
||||
pool.with do
|
||||
assert_raises Timeout::Error do
|
||||
Thread.new { pool.checkout }.join
|
||||
end
|
||||
Thread.new do
|
||||
assert_raises Timeout::Error do
|
||||
pool.checkout
|
||||
end
|
||||
end.join
|
||||
end
|
||||
|
||||
assert Thread.new { pool.checkout }.join
|
||||
|
@ -204,9 +206,11 @@ class TestConnectionPool < Minitest::Test
|
|||
pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
|
||||
conn = pool.checkout
|
||||
|
||||
assert_raises Timeout::Error do
|
||||
Thread.new { pool.checkout }.join
|
||||
end
|
||||
Thread.new do
|
||||
assert_raises Timeout::Error do
|
||||
pool.checkout
|
||||
end
|
||||
end.join
|
||||
|
||||
pool.checkin
|
||||
|
||||
|
@ -247,11 +251,11 @@ class TestConnectionPool < Minitest::Test
|
|||
|
||||
pool.checkin
|
||||
|
||||
assert_raises Timeout::Error do
|
||||
Thread.new do
|
||||
Thread.new do
|
||||
assert_raises Timeout::Error do
|
||||
pool.checkout
|
||||
end.join
|
||||
end
|
||||
end
|
||||
end.join
|
||||
|
||||
pool.checkin
|
||||
|
||||
|
@ -475,11 +479,11 @@ class TestConnectionPool < Minitest::Test
|
|||
wrapper = ConnectionPool::Wrapper.new(timeout: 0, size: 1) { Object.new }
|
||||
|
||||
wrapper.with do
|
||||
assert_raises Timeout::Error do
|
||||
Thread.new do
|
||||
Thread.new do
|
||||
assert_raises Timeout::Error do
|
||||
wrapper.with { flunk 'connection checked out :(' }
|
||||
end.join
|
||||
end
|
||||
end
|
||||
end.join
|
||||
end
|
||||
|
||||
assert Thread.new { wrapper.with { } }.join
|
||||
|
|
Loading…
Reference in a new issue