changes needed due to 3c91978d36

add posibility to inspect availability of a resource in a pool (testing only)
allow access to internal connection pool of db (testing only)
This commit is contained in:
Brian J. Cardiff 2016-08-29 13:14:47 -03:00
parent 3c91978d36
commit 8d891a5a4e
4 changed files with 28 additions and 1 deletions

View file

@ -59,6 +59,25 @@ describe DB::Pool do
pool.checkout.should be_a Closable
end
it "should be available if not checkedout" do
resource = uninitialized Closable
pool = DB::Pool.new(initial_pool_size: 1) { resource = Closable.new }
pool.is_available?(resource).should be_true
end
it "should not be available if checkedout" do
pool = DB::Pool.new { Closable.new }
resource = pool.checkout
pool.is_available?(resource).should be_false
end
it "should be available if returned" do
pool = DB::Pool.new { Closable.new }
resource = pool.checkout
pool.release resource
pool.is_available?(resource).should be_true
end
it "should wait for available resource" do
pool = DB::Pool.new(max_pool_size: 1, initial_pool_size: 1) { Closable.new }