/**
 * On first borrow, first object fails validation, second object is OK.
 * Subsequent borrows are OK. This was POOL-152.
 */
On first borrow, first object fails validation, second object is OK.
Subsequent borrows are OK. This was POOL-152.
/ ** * On first borrow first object fails validation second object is OK . * Subsequent borrows are OK . This was POOL - 152 . * /
func (suit *PoolTestSuite) TestBrokenFactoryShouldNotBlockPool() {
	maxTotal := 1
	suit.factory.maxTotal = maxTotal
	suit.pool.Config.MaxTotal = maxTotal
	suit.pool.Config.BlockWhenExhausted = true
	suit.pool.Config.TestOnBorrow = true
	suit.factory.setValid(false)
	obj, ex := suit.pool.BorrowObject()
	_, ok := ex.(*NoSuchElementErr)
	suit.True(ok, "expect NoSuchElementErr, but get: %v", reflect.TypeOf(ex))
	suit.Nil(obj)
	suit.factory.setValid(true)
	obj = suit.NoErrorWithResult(suit.pool.BorrowObject())
	suit.NoError(suit.pool.ReturnObject(obj))
}
func ( suit * PoolTestSuite ) TestBrokenFactoryShouldNotBlockPool ( ) { maxTotal := 1 suit . factory . maxTotal = maxTotal suit . pool . Config . MaxTotal = maxTotal suit . pool . Config . BlockWhenExhausted = true suit . pool . Config . TestOnBorrow = true suit . factory . setValid ( false ) obj , ex := suit . pool . BorrowObject ( ) _ , ok := ex . ( * NoSuchElementErr ) suit . True ( ok , " " , reflect . TypeOf ( ex ) ) suit . Nil ( obj ) suit . factory . setValid ( true ) obj = suit . NoErrorWithResult ( suit . pool . BorrowObject ( ) ) suit . NoError ( suit . pool . ReturnObject ( obj ) ) }
On first borrow, first object fails validation, second object is OK.
On first borrow first object fails validation second object is OK .
// First borrow object will need to create a new object which will fail // validation. // Failure expected // Configure factory to create valid objects so subsequent borrows work // Subsequent borrows should be OK