File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 426426 end
427427 end
428428
429- describe 'connection pool error handling ' do
429+ describe 'when connection pool is exhausted ' do
430430 before do
431- expect ( subject ) . to_not receive ( :check_in )
431+ max_pool_size . times { subject . check_out }
432432 end
433433
434- it 'does not add nil to the pool when full and an attempt is made to use it' do
435- conns = max_pool_size . times . map { subject . check_out }
436- expect { subject . query ( 'select 1' ) } . to raise_error ( RuntimeError )
437- # Previous versions had a bug where a nil would be added to the pool
438- # at this point.
439- expect { subject . connections . pop ( true ) } . to raise_error ( ThreadError )
434+ it 'pop throws exception' do
435+ expect { subject . connections . pop ( true ) } . to raise_error ( ThreadError )
436+ end
437+
438+ it 'throws exception on query' do
439+ expect { subject . query ( 'SELECT 1' ) } . to raise_error ( RuntimeError , /depleted/ )
440+ end
441+
442+ it 'does not put nil in the pool on error' do
443+ expect ( subject ) . to_not receive ( :check_in ) . with ( nil )
444+ expect { subject . query ( 'SELECT 1' ) } . to raise_error ( RuntimeError , /depleted/ )
440445 end
441446 end
442447end
You can’t perform that action at this time.
0 commit comments