summaryrefslogtreecommitdiff
path: root/pipe_factory_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-12-23 14:43:47 +0300
committerWolfy-J <[email protected]>2019-12-23 14:43:47 +0300
commitc7b0a4a81827284f7565c56aa476eea34fb6382f (patch)
treeee30e93169c37fb058fbe55af6b3f954eabd9646 /pipe_factory_test.go
parent7f694966730f6dac09d0d0ea3bf51276b8e4dfe4 (diff)
- test fixes
Diffstat (limited to 'pipe_factory_test.go')
-rw-r--r--pipe_factory_test.go46
1 files changed, 37 insertions, 9 deletions
diff --git a/pipe_factory_test.go b/pipe_factory_test.go
index 9d50e47f..27d1f74d 100644
--- a/pipe_factory_test.go
+++ b/pipe_factory_test.go
@@ -17,12 +17,15 @@ func Test_Pipe_Start(t *testing.T) {
assert.NoError(t, w.Wait())
}()
- w.Stop()
+ assert.NoError(t, w.Stop())
}
func Test_Pipe_StartError(t *testing.T) {
cmd := exec.Command("php", "tests/client.php", "echo", "pipes")
- cmd.Start()
+ err := cmd.Start()
+ if err != nil {
+ t.Errorf("error running the command: error %v", err)
+ }
w, err := NewPipeFactory().SpawnWorker(cmd)
assert.Error(t, err)
@@ -31,7 +34,10 @@ func Test_Pipe_StartError(t *testing.T) {
func Test_Pipe_PipeError(t *testing.T) {
cmd := exec.Command("php", "tests/client.php", "echo", "pipes")
- cmd.StdinPipe()
+ _, err := cmd.StdinPipe()
+ if err != nil {
+ t.Errorf("error creating the STDIN pipe: error %v", err)
+ }
w, err := NewPipeFactory().SpawnWorker(cmd)
assert.Error(t, err)
@@ -40,7 +46,10 @@ func Test_Pipe_PipeError(t *testing.T) {
func Test_Pipe_PipeError2(t *testing.T) {
cmd := exec.Command("php", "tests/client.php", "echo", "pipes")
- cmd.StdoutPipe()
+ _, err := cmd.StdinPipe()
+ if err != nil {
+ t.Errorf("error creating the STDIN pipe: error %v", err)
+ }
w, err := NewPipeFactory().SpawnWorker(cmd)
assert.Error(t, err)
@@ -71,7 +80,12 @@ func Test_Pipe_Echo(t *testing.T) {
go func() {
assert.NoError(t, w.Wait())
}()
- defer w.Stop()
+ defer func() {
+ err := w.Stop()
+ if err != nil {
+ t.Errorf("error stopping the worker: error %v", err)
+ }
+ }()
res, err := w.Exec(&Payload{Body: []byte("hello")})
@@ -93,7 +107,10 @@ func Test_Pipe_Broken(t *testing.T) {
assert.Error(t, err)
assert.Contains(t, err.Error(), "undefined_function()")
}()
- defer w.Stop()
+ defer func() {
+ err := w.Stop()
+ assert.Error(t, err)
+ }()
res, err := w.Exec(&Payload{Body: []byte("hello")})
@@ -112,7 +129,10 @@ func Benchmark_Pipe_SpawnWorker_Stop(b *testing.B) {
}
}()
- w.Stop()
+ err := w.Stop()
+ if err != nil {
+ b.Errorf("error stopping the worker: error %v", err)
+ }
}
}
@@ -121,9 +141,17 @@ func Benchmark_Pipe_Worker_ExecEcho(b *testing.B) {
w, _ := NewPipeFactory().SpawnWorker(cmd)
go func() {
- w.Wait()
+ err := w.Wait()
+ if err != nil {
+ b.Errorf("error waiting the worker: error %v", err)
+ }
+ }()
+ defer func() {
+ err := w.Stop()
+ if err != nil {
+ b.Errorf("error stopping the worker: error %v", err)
+ }
}()
- defer w.Stop()
for n := 0; n < b.N; n++ {
if _, err := w.Exec(&Payload{Body: []byte("hello")}); err != nil {