Sha256: 0ad3fb73055ba5babeece0496411906b01d1a82ea58f9dafc45ea2486022e560
Contents?: true
Size: 1.43 KB
Versions: 10
Compression:
Stored size: 1.43 KB
Contents
require "cases/helper" module ActiveRecord module ConnectionAdapters class AdapterLeasingTest < ActiveRecord::TestCase class Pool < ConnectionPool def insert_connection_for_test!(c) synchronize do @connections << c @available.add c end end end def setup @adapter = AbstractAdapter.new nil, nil end def test_in_use? assert_not @adapter.in_use?, 'adapter is not in use' assert @adapter.lease, 'lease adapter' assert @adapter.in_use?, 'adapter is in use' end def test_lease_twice assert @adapter.lease, 'should lease adapter' assert_not @adapter.lease, 'should not lease adapter' end def test_expire_mutates_in_use assert @adapter.lease, 'lease adapter' assert @adapter.in_use?, 'adapter is in use' @adapter.expire assert_not @adapter.in_use?, 'adapter is in use' end def test_close pool = Pool.new(ConnectionSpecification.new({}, nil)) pool.insert_connection_for_test! @adapter @adapter.pool = pool # Make sure the pool marks the connection in use assert_equal @adapter, pool.connection assert @adapter.in_use? # Close should put the adapter back in the pool @adapter.close assert_not @adapter.in_use? assert_equal @adapter, pool.connection end end end end
Version data entries
10 entries across 10 versions & 2 rubygems