-
Notifications
You must be signed in to change notification settings - Fork 2
/
pooled_actuator_test.go
57 lines (45 loc) · 1006 Bytes
/
pooled_actuator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package conexec
import (
"testing"
"time"
"github.com/panjf2000/ants/v2"
)
func TestPooledTimeOut(t *testing.T) {
timeout := time.Millisecond * 50
opt := &Options{TimeOut: &timeout}
c := NewPooledActuator(5, opt)
testTimeout(t, c)
c = NewPooledActuator(-1, opt)
testTimeout(t, c)
}
func TestPooledError(t *testing.T) {
timeout := time.Second
opt := &Options{TimeOut: &timeout}
c := NewPooledActuator(5, opt)
testError(t, c)
}
func TestPooledNormal(t *testing.T) {
c := NewPooledActuator(5)
testNormal(t, c)
timeout := time.Minute
opt := &Options{TimeOut: &timeout}
c = NewPooledActuator(5, opt)
testNormal(t, c)
c.Release()
c = &PooledActuator{}
testNormal(t, c)
}
func TestPooledEmpty(t *testing.T) {
c := NewPooledActuator(5)
testEmpty(t, c)
}
func TestPooledPanic(t *testing.T) {
c := NewPooledActuator(5)
testPanic(t, c)
}
func TestWithPool(t *testing.T) {
pool, _ := ants.NewPool(5)
c := NewPooledActuator(5).WithPool(pool)
testNormal(t, c)
testError(t, c)
}