diff options
author | Valery Piashchynski <[email protected]> | 2020-02-28 10:48:34 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-28 10:48:34 +0300 |
commit | 33f92daae1ecf9b9388cf3adb22a0efd2c3467d9 (patch) | |
tree | 1c6a84526a1e879f0d96e1bf219ab74a19d2731d | |
parent | b3c8c7170bb9a7d5b218faf84d7a5f17cb15404d (diff) |
Update service_tests
-rw-r--r-- | service/static/service_test.go | 21 | ||||
-rw-r--r-- | static_pool_test.go | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/service/static/service_test.go b/service/static/service_test.go index 4205650d..bcda26ce 100644 --- a/service/static/service_test.go +++ b/service/static/service_test.go @@ -90,11 +90,13 @@ func Test_Files(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + + time.Sleep(time.Second) + b, _, _ := get("http://localhost:6029/sample.txt") assert.Equal(t, "sample", b) + c.Stop() } func Test_Disabled(t *testing.T) { @@ -334,11 +336,12 @@ func Test_Files_NotFound(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + + time.Sleep(time.Second) b, _, _ := get("http://localhost:6029/client.XXX?hello=world") assert.Equal(t, "WORLD", b) + c.Stop() } func Test_Files_Dir(t *testing.T) { @@ -376,11 +379,11 @@ func Test_Files_Dir(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + time.Sleep(time.Second) b, _, _ := get("http://localhost:6029/http?hello=world") assert.Equal(t, "WORLD", b) + c.Stop() } func Test_Files_NotForbid(t *testing.T) { @@ -418,11 +421,13 @@ func Test_Files_NotForbid(t *testing.T) { t.Errorf("serve error: %v", err) } }() - time.Sleep(time.Millisecond * 100) - defer c.Stop() + + time.Sleep(time.Second) b, _, _ := get("http://localhost:6029/client.php") assert.Equal(t, all("../../tests/client.php"), b) + assert.Equal(t, all("../../tests/client.php"), b) + c.Stop() } func tmpDir() string { diff --git a/static_pool_test.go b/static_pool_test.go index 3fd8dc78..59822186 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -151,11 +151,10 @@ func Test_StaticPool_Broken_Replace(t *testing.T) { cfg, ) assert.NoError(t, err) - defer p.Destroy() - assert.NotNil(t, p) done := make(chan interface{}) + p.Listen(func(e int, ctx interface{}) { if err, ok := ctx.(error); ok { if strings.Contains(err.Error(), "undefined_function()") { @@ -170,8 +169,10 @@ func Test_StaticPool_Broken_Replace(t *testing.T) { assert.Nil(t, res) <-done + p.Destroy() } + func Test_StaticPool_Broken_FromOutside(t *testing.T) { p, err := NewPool( func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") }, |