summaryrefslogtreecommitdiff
path: root/pool_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-01-28 15:25:57 +0300
committerWolfy-J <[email protected]>2018-01-28 15:25:57 +0300
commitcb7629dbe105e6ee2bf9b2b1f3619dff596d0aa1 (patch)
tree26a5d6c2077b1cd77878fa009ff4fca448827e5b /pool_test.go
parenta28ac27bd762ad65ff4cbbeaa8e2b03c9f0d1c32 (diff)
head parsing for raw data
Diffstat (limited to 'pool_test.go')
-rw-r--r--pool_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/pool_test.go b/pool_test.go
index 0ce7be26..76c93b60 100644
--- a/pool_test.go
+++ b/pool_test.go
@@ -75,6 +75,48 @@ func Test_Pool_Echo(t *testing.T) {
assert.Equal(t, "hello", res.String())
}
+func Test_Pool_Echo_NilHead(t *testing.T) {
+ p, err := NewPool(
+ func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") },
+ NewPipeFactory(),
+ cfg,
+ )
+ defer p.Destroy()
+
+ assert.NotNil(t, p)
+ assert.NoError(t, err)
+
+ res, err := p.Exec(&Payload{Body: []byte("hello"), Head: nil})
+
+ assert.NoError(t, err)
+ assert.NotNil(t, res)
+ assert.NotNil(t, res.Body)
+ assert.Nil(t, res.Head)
+
+ assert.Equal(t, "hello", res.String())
+}
+
+func Test_Pool_Echo_Head(t *testing.T) {
+ p, err := NewPool(
+ func() *exec.Cmd { return exec.Command("php", "tests/client.php", "head", "pipes") },
+ NewPipeFactory(),
+ cfg,
+ )
+ defer p.Destroy()
+
+ assert.NotNil(t, p)
+ assert.NoError(t, err)
+
+ res, err := p.Exec(&Payload{Body: []byte("hello"), Head: []byte("world")})
+
+ assert.NoError(t, err)
+ assert.NotNil(t, res)
+ assert.Nil(t, res.Body)
+ assert.NotNil(t, res.Head)
+
+ assert.Equal(t, "world", string(res.Head))
+}
+
func Test_Pool_AllocateTimeout(t *testing.T) {
p, err := NewPool(
func() *exec.Cmd { return exec.Command("php", "tests/client.php", "delay", "pipes") },