diff options
author | Wolfy-J <[email protected]> | 2018-06-07 16:31:56 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-07 16:31:56 +0300 |
commit | b1a324e9b230f7db114fe7264019f86ff1875e16 (patch) | |
tree | 1b4f8e0fde2b0c310957336c3221330d62f39a46 | |
parent | e74adb2b42e6c75b8235190dcaf01988aed3191e (diff) |
more tests
-rw-r--r-- | worker_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/worker_test.go b/worker_test.go index cb88d797..0132e33e 100644 --- a/worker_test.go +++ b/worker_test.go @@ -43,6 +43,23 @@ func Test_Echo(t *testing.T) { assert.Equal(t, "hello", res.String()) } +func Test_BadPayload(t *testing.T) { + cmd := exec.Command("php", "php-src/tests/client.php", "echo", "pipes") + + w, _ := NewPipeFactory().SpawnWorker(cmd) + go func() { + assert.NoError(t, w.Wait()) + }() + defer w.Stop() + + res, err := w.Exec(nil) + + assert.Error(t, err) + assert.Nil(t, res) + + assert.Equal(t, "payload can not be empty", err.Error()) +} + func Test_NotStarted_String(t *testing.T) { cmd := exec.Command("php", "php-src/tests/client.php", "echo", "pipes") @@ -52,6 +69,19 @@ func Test_NotStarted_String(t *testing.T) { assert.Contains(t, w.String(), "numExecs: 0") } +func Test_NotStarted_Exec(t *testing.T) { + cmd := exec.Command("php", "php-src/tests/client.php", "echo", "pipes") + + w, _ := newWorker(cmd) + + res, err := w.Exec(&Payload{Body: []byte("hello")}) + + assert.Error(t, err) + assert.Nil(t, res) + + assert.Equal(t, "worker is not ready (inactive)", err.Error()) +} + func Test_String(t *testing.T) { cmd := exec.Command("php", "php-src/tests/client.php", "echo", "pipes") |