diff options
Diffstat (limited to 'pkg/transport/pipe')
-rw-r--r-- | pkg/transport/pipe/pipe_factory_spawn_test.go | 14 | ||||
-rwxr-xr-x | pkg/transport/pipe/pipe_factory_test.go | 16 |
2 files changed, 26 insertions, 4 deletions
diff --git a/pkg/transport/pipe/pipe_factory_spawn_test.go b/pkg/transport/pipe/pipe_factory_spawn_test.go index e247324c..663b3dd5 100644 --- a/pkg/transport/pipe/pipe_factory_spawn_test.go +++ b/pkg/transport/pipe/pipe_factory_spawn_test.go @@ -106,11 +106,21 @@ func Test_Pipe_PipeError4(t *testing.T) { func Test_Pipe_Failboot2(t *testing.T) { cmd := exec.Command("php", "../../../tests/failboot.php") - w, err := NewPipeFactory().SpawnWorker(cmd) + finish := make(chan struct{}, 1) + listener := func(event interface{}) { + if ev, ok := event.(events.WorkerEvent); ok { + if ev.Event == events.EventWorkerStderr { + if strings.Contains(string(ev.Payload.([]byte)), "failboot") { + finish <- struct{}{} + } + } + } + } + w, err := NewPipeFactory().SpawnWorker(cmd, listener) assert.Nil(t, w) assert.Error(t, err) - assert.Contains(t, err.Error(), "failboot") + <-finish } func Test_Pipe_Invalid2(t *testing.T) { diff --git a/pkg/transport/pipe/pipe_factory_test.go b/pkg/transport/pipe/pipe_factory_test.go index b23af19f..6045dd91 100755 --- a/pkg/transport/pipe/pipe_factory_test.go +++ b/pkg/transport/pipe/pipe_factory_test.go @@ -117,11 +117,23 @@ func Test_Pipe_PipeError2(t *testing.T) { func Test_Pipe_Failboot(t *testing.T) { cmd := exec.Command("php", "../../../tests/failboot.php") ctx := context.Background() - w, err := NewPipeFactory().SpawnWorkerWithTimeout(ctx, cmd) + + finish := make(chan struct{}, 1) + listener := func(event interface{}) { + if ev, ok := event.(events.WorkerEvent); ok { + if ev.Event == events.EventWorkerStderr { + if strings.Contains(string(ev.Payload.([]byte)), "failboot") { + finish <- struct{}{} + } + } + } + } + + w, err := NewPipeFactory().SpawnWorkerWithTimeout(ctx, cmd, listener) assert.Nil(t, w) assert.Error(t, err) - assert.Contains(t, err.Error(), "failboot") + <-finish } func Test_Pipe_Invalid(t *testing.T) { |