diff options
author | Valery Piashchynski <[email protected]> | 2020-02-28 13:05:43 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-28 13:05:43 +0300 |
commit | dc8a2e62cbb1c1ed07dc51f5629950211587d5a4 (patch) | |
tree | c1bf85b7315b5da5eb6e8fb40918d90df45c7f55 /static_pool_test.go | |
parent | 116d338930665a374670ed571fa8a9e0078c43ad (diff) |
Test_StaticPool_AllocateTimeout update
Diffstat (limited to 'static_pool_test.go')
-rw-r--r-- | static_pool_test.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/static_pool_test.go b/static_pool_test.go index 565f4686..6cbd659e 100644 --- a/static_pool_test.go +++ b/static_pool_test.go @@ -219,7 +219,7 @@ func Test_StaticPool_AllocateTimeout(t *testing.T) { NewPipeFactory(), Config{ NumWorkers: 1, - AllocateTimeout: time.Nanosecond * 1, + AllocateTimeout: time.Millisecond * 50, DestroyTimeout: time.Second * 2, }, ) @@ -228,26 +228,25 @@ func Test_StaticPool_AllocateTimeout(t *testing.T) { } done := make(chan interface{}) - go func() { if p != nil { _, err := p.Exec(&Payload{Body: []byte("100")}) assert.NoError(t, err) close(done) } else { - panic("Pool is nil") + t.Fatal("Pool is nil") } + }() - // to ensure that worker is already busy - time.Sleep(time.Millisecond * 100) - _, err = p.Exec(&Payload{Body: []byte("10")}) - if err == nil { - t.Fatal("Test_StaticPool_AllocateTimeout exec should raise error") - } - assert.Contains(t, err.Error(), "worker timeout") - }() + // to ensure that worker is already busy + time.Sleep(time.Millisecond * 10) + _, err = p.Exec(&Payload{Body: []byte("10")}) + if err == nil { + t.Fatal("Test_StaticPool_AllocateTimeout exec should raise error") + } + assert.Contains(t, err.Error(), "worker timeout") <-done p.Destroy() |