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 = ConnectionPool.new(timeout: 0, size: 1) { Object.new }
|
||||||
|
|
||||||
pool.with do
|
pool.with do
|
||||||
assert_raises Timeout::Error do
|
Thread.new do
|
||||||
Thread.new { pool.checkout }.join
|
assert_raises Timeout::Error do
|
||||||
end
|
pool.checkout
|
||||||
|
end
|
||||||
|
end.join
|
||||||
end
|
end
|
||||||
|
|
||||||
assert Thread.new { pool.checkout }.join
|
assert Thread.new { pool.checkout }.join
|
||||||
|
@ -204,9 +206,11 @@ class TestConnectionPool < Minitest::Test
|
||||||
pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
|
pool = ConnectionPool.new(timeout: 0, size: 1) { NetworkConnection.new }
|
||||||
conn = pool.checkout
|
conn = pool.checkout
|
||||||
|
|
||||||
assert_raises Timeout::Error do
|
Thread.new do
|
||||||
Thread.new { pool.checkout }.join
|
assert_raises Timeout::Error do
|
||||||
end
|
pool.checkout
|
||||||
|
end
|
||||||
|
end.join
|
||||||
|
|
||||||
pool.checkin
|
pool.checkin
|
||||||
|
|
||||||
|
@ -247,11 +251,11 @@ class TestConnectionPool < Minitest::Test
|
||||||
|
|
||||||
pool.checkin
|
pool.checkin
|
||||||
|
|
||||||
assert_raises Timeout::Error do
|
Thread.new do
|
||||||
Thread.new do
|
assert_raises Timeout::Error do
|
||||||
pool.checkout
|
pool.checkout
|
||||||
end.join
|
end
|
||||||
end
|
end.join
|
||||||
|
|
||||||
pool.checkin
|
pool.checkin
|
||||||
|
|
||||||
|
@ -475,11 +479,11 @@ class TestConnectionPool < Minitest::Test
|
||||||
wrapper = ConnectionPool::Wrapper.new(timeout: 0, size: 1) { Object.new }
|
wrapper = ConnectionPool::Wrapper.new(timeout: 0, size: 1) { Object.new }
|
||||||
|
|
||||||
wrapper.with do
|
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 :(' }
|
wrapper.with { flunk 'connection checked out :(' }
|
||||||
end.join
|
end
|
||||||
end
|
end.join
|
||||||
end
|
end
|
||||||
|
|
||||||
assert Thread.new { wrapper.with { } }.join
|
assert Thread.new { wrapper.with { } }.join
|
||||||
|
|
Loading…
Reference in a new issue