summaryrefslogtreecommitdiff
path: root/worker_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-07 16:31:56 +0300
committerWolfy-J <[email protected]>2018-06-07 16:31:56 +0300
commitb1a324e9b230f7db114fe7264019f86ff1875e16 (patch)
tree1b4f8e0fde2b0c310957336c3221330d62f39a46 /worker_test.go
parente74adb2b42e6c75b8235190dcaf01988aed3191e (diff)
more tests
Diffstat (limited to 'worker_test.go')
-rw-r--r--worker_test.go30
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")