diff options
author | Valery Piashchynski <[email protected]> | 2020-12-03 13:41:23 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-03 13:41:23 +0300 |
commit | 1a2d525dfb5b8d1d59c93da79fabcf2ca3f5c56d (patch) | |
tree | 46a0d9250b2a5b37e0b93887e28e9a06bc960021 | |
parent | 9f6933832a006030c61321914c84cd4aed80718b (diff) |
Experimental to replace wg with strings compare
-rwxr-xr-x | sync_worker_test.go | 18 | ||||
-rwxr-xr-x | util/events.go | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/sync_worker_test.go b/sync_worker_test.go index c4febbb4..b44efd2e 100755 --- a/sync_worker_test.go +++ b/sync_worker_test.go @@ -3,8 +3,9 @@ package roadrunner import ( "context" "os/exec" - "sync" + "strings" "testing" + "time" "github.com/spiral/errors" "github.com/stretchr/testify/assert" @@ -160,13 +161,11 @@ func Test_Broken(t *testing.T) { t.Fatal(err) } - wg := &sync.WaitGroup{} - wg.Add(1) - + data := "" w.AddListener(func(event interface{}) { - assert.Contains(t, string(event.(WorkerEvent).Payload.([]byte)), "undefined_function()") - wg.Done() - return + if wev, ok := event.(WorkerEvent); ok { + data = string(wev.Payload.([]byte)) + } }) syncWorker, err := NewSyncWorker(w) @@ -179,7 +178,10 @@ func Test_Broken(t *testing.T) { assert.Nil(t, res.Body) assert.Nil(t, res.Context) - wg.Wait() + time.Sleep(time.Second * 3) + if strings.ContainsAny(data, "undefined_function()") == false { + t.Fail() + } assert.Error(t, w.Stop(ctx)) } diff --git a/util/events.go b/util/events.go index 21ebc29b..43a3e646 100755 --- a/util/events.go +++ b/util/events.go @@ -6,7 +6,7 @@ type EventsHandler interface { Push(e interface{}) } -// Event listener listens for the events produced by worker, worker pool or other servce. +// Event listener listens for the events produced by worker, worker pool or other service. type EventListener func(event interface{}) // EventHandler helps to broadcast events to multiple listeners. |