diff options
author | Wolfy-J <[email protected]> | 2018-09-23 15:26:10 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-23 15:26:10 +0300 |
commit | 892d5949ae95e0b8284746ef368e6f0b6316680d (patch) | |
tree | 346f5dbd2e22f768b7629caa4b81f32fd2ae4f97 /static_pool_test.go | |
parent | d32e3935fc49d8f020954aad2b14e367b8bc6eeb (diff) |
more coverage
Diffstat (limited to 'static_pool_test.go')
-rw-r--r-- | static_pool_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/static_pool_test.go b/static_pool_test.go index ab8d89e4..036cd092 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -303,6 +303,49 @@ func Test_StaticPool_Stop_Worker(t *testing.T) { } } +// identical to replace but controlled on worker side +func Test_Static_Pool_Destroy_And_Close(t *testing.T) { + p, err := NewPool( + func() *exec.Cmd { return exec.Command("php", "tests/client.php", "delay", "pipes") }, + NewPipeFactory(), + Config{ + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + ) + + assert.NotNil(t, p) + assert.NoError(t, err) + + p.Destroy() + _, err = p.Exec(&Payload{Body: []byte("100")}) + assert.Error(t, err) +} + +// identical to replace but controlled on worker side +func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) { + p, err := NewPool( + func() *exec.Cmd { return exec.Command("php", "tests/client.php", "delay", "pipes") }, + NewPipeFactory(), + Config{ + NumWorkers: 1, + AllocateTimeout: time.Second, + DestroyTimeout: time.Second, + }, + ) + + assert.NotNil(t, p) + assert.NoError(t, err) + + go p.Exec(&Payload{Body: []byte("100")}) + time.Sleep(time.Millisecond * 10) + + p.Destroy() + _, err = p.Exec(&Payload{Body: []byte("100")}) + assert.Error(t, err) +} + func Benchmark_Pool_Allocate(b *testing.B) { p, _ := NewPool( func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, |