gopkg
gopkg copied to clipboard
test: fix TestPoolPanic in gopool
This PR tries to fix the TestPoolPanic function in gopool. Currently it only contains the following test logic
p := NewPool("test", 100, NewConfig())
p.Go(testPanicFunc)
Maybe the original idea is to see if any panic occurs. But actually, the p.Go
goroutine is not guaranteed to be executed before the main goroutine exits. Chances are testPanicFunc
never get called. So this test case is actually useless.
I add sync.WaitGroup to wait for sub goroutines to finish. Also we need to check if SetPanicHandler
is working correctly, so I compared the actual execute times with expected times to see if provided panic handler does get called every time when panic occurs.