diff options
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() |