summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-30 17:04:08 +0300
committerValery Piashchynski <[email protected]>2020-11-30 17:04:08 +0300
commit2ac6d3192fbd43f0911d7c87f394fd0839b0fcfa (patch)
treecf017dfe32dbafbcd7aacbaa130e47961adca927
parentb0432d74abdc2b9484aeb4b2215077348e3be5eb (diff)
Fix issue with TestBrokenReplace when listening to every worker instead
of listening on Pool
-rwxr-xr-xstatic_pool_test.go32
1 files changed, 8 insertions, 24 deletions
diff --git a/static_pool_test.go b/static_pool_test.go
index b29b60ae..77e554e5 100755
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -174,30 +174,15 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
wg := &sync.WaitGroup{}
wg.Add(1)
- // force test to finish
- tt := time.NewTimer(time.Second * 30)
- go func() {
- select {
- case <-tt.C:
- tt.Stop()
- assert.Fail(t, "force exit from the test")
- wg.Done()
- }
- }()
-
- workers := p.Workers()
- for i := 0; i < len(workers); i++ {
- workers[i].AddListener(func(event interface{}) {
- if wev, ok := event.(WorkerEvent); ok {
- if wev.Event == EventWorkerLog {
- assert.Contains(t, string(wev.Payload.([]byte)), "undefined_function()")
- wg.Done()
- tt.Stop()
- return
- }
+ p.AddListener(func(event interface{}) {
+ if wev, ok := event.(WorkerEvent); ok {
+ if wev.Event == EventWorkerLog {
+ assert.Contains(t, string(wev.Payload.([]byte)), "undefined_function()")
+ wg.Done()
+ return
}
- })
- }
+ }
+ })
res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.Error(t, err)
@@ -205,7 +190,6 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
assert.Nil(t, res.Body)
wg.Wait()
- tt.Stop()
p.Destroy(ctx)
}