From 17ff88c4d425d7b55ff1a1225cb56f293e7dd7eb Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 30 Dec 2011 14:09:39 -0800 Subject: connections can be removed from the pool --- activerecord/test/cases/connection_pool_test.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'activerecord/test/cases') diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb index 5b5bbc6500..d4d0f6258d 100644 --- a/activerecord/test/cases/connection_pool_test.rb +++ b/activerecord/test/cases/connection_pool_test.rb @@ -4,6 +4,8 @@ module ActiveRecord module ConnectionAdapters class ConnectionPoolTest < ActiveRecord::TestCase def setup + super + # Keep a duplicate pool so we do not bother others @pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec @@ -18,6 +20,23 @@ module ActiveRecord end end + def teardown + super + @pool.connections.each(&:close) + end + + def test_remove_connection + conn = @pool.checkout + assert conn.in_use? + + length = @pool.connections.length + @pool.remove conn + assert conn.in_use? + assert_equal(length - 1, @pool.connections.length) + ensure + conn.close + end + def test_active_connection? assert !@pool.active_connection? assert @pool.connection -- cgit v1.2.3