summaryrefslogtreecommitdiff
path: root/sync_worker_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-03 13:14:29 +0300
committerValery Piashchynski <[email protected]>2020-12-03 13:14:29 +0300
commitf86e67bcc90560cd907df5abbf5ca7b3fcbe8ca1 (patch)
treeafcc2897a198fe747bc8673cd8bd9b2d6fe709a1 /sync_worker_test.go
parent31e4bb7b236fe0ae59fd42d66af0d718b67a2a4b (diff)
Correct Test_Broken test, replace channel with wait group
Diffstat (limited to 'sync_worker_test.go')
-rwxr-xr-xsync_worker_test.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/sync_worker_test.go b/sync_worker_test.go
index 9786d709..890a2365 100755
--- a/sync_worker_test.go
+++ b/sync_worker_test.go
@@ -3,8 +3,8 @@ package roadrunner
import (
"context"
"os/exec"
+ "sync"
"testing"
- "time"
"github.com/spiral/errors"
"github.com/stretchr/testify/assert"
@@ -159,20 +159,13 @@ func Test_Broken(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- ch := make(chan struct{})
- go func() {
- tt := time.NewTimer(time.Second * 10)
- select {
- case <-tt.C:
- tt.Stop()
- ch <- struct{}{}
- }
- }()
+ wg := &sync.WaitGroup{}
+ wg.Add(1)
w.AddListener(func(event interface{}) {
assert.Contains(t, string(event.(WorkerEvent).Payload.([]byte)), "undefined_function()")
- ch <- struct{}{}
+ wg.Done()
})
syncWorker, err := NewSyncWorker(w)
@@ -185,7 +178,7 @@ func Test_Broken(t *testing.T) {
assert.Nil(t, res.Body)
assert.Nil(t, res.Context)
- <-ch
+ wg.Wait()
assert.Error(t, w.Stop(ctx))
}