From 13a85414cf4d7fe031656891fbd64e2b800500d5 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 14 Feb 2014 15:07:35 -0800 Subject: [PATCH] Test checkin after multiple checkouts The local thread records how many times a connection has been checked out so it can be returned to the pool when all have been checked in. --- test/test_connection_pool.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_connection_pool.rb b/test/test_connection_pool.rb index d4f2949..f790a38 100644 --- a/test/test_connection_pool.rb +++ b/test/test_connection_pool.rb @@ -130,6 +130,25 @@ class TestConnectionPool < Minitest::Test end end + def test_checkin_twice + pool = ConnectionPool.new(:timeout => 0, :size => 1) { Object.new } + + pool.checkout + pool.checkout + + pool.checkin + + assert_raises Timeout::Error do + Thread.new do + pool.checkout + end.join + end + + pool.checkin + + assert Thread.new { pool.checkout }.join + end + def test_checkout pool = ConnectionPool.new(:size => 1) { NetworkConnection.new }