summaryrefslogtreecommitdiff
path: root/static_pool_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-19 14:01:59 +0300
committerValery Piashchynski <[email protected]>2020-10-19 14:01:59 +0300
commit77670fb7af0c892c9b3a589fd424534fad288e7a (patch)
tree3adcaa85db664a355abe2b28f1d7e4a3fc45689f /static_pool_test.go
parent16fbf3104c3c34bd9355593052b686acd26a8efe (diff)
Update according activity worker
Diffstat (limited to 'static_pool_test.go')
-rw-r--r--static_pool_test.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/static_pool_test.go b/static_pool_test.go
index b2ab4713..fd8124ac 100644
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -50,7 +50,7 @@ func Test_StaticPool_Invalid(t *testing.T) {
assert.Error(t, err)
}
-func Test_ConfigError(t *testing.T) {
+func Test_ConfigNoErrorInitDefaults(t *testing.T) {
p, err := NewPool(
context.Background(),
func() *exec.Cmd { return exec.Command("php", "tests/client.php", "echo", "pipes") },
@@ -61,8 +61,8 @@ func Test_ConfigError(t *testing.T) {
},
)
- assert.Nil(t, p)
- assert.Error(t, err)
+ assert.NotNil(t, p)
+ assert.NoError(t, err)
}
func Test_StaticPool_Echo(t *testing.T) {
@@ -79,7 +79,7 @@ func Test_StaticPool_Echo(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -103,7 +103,7 @@ func Test_StaticPool_Echo_NilContext(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(ctx, Payload{Body: []byte("hello"), Context: nil})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello"), Context: nil})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -127,7 +127,7 @@ func Test_StaticPool_Echo_Context(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(ctx, Payload{Body: []byte("hello"), Context: []byte("world")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello"), Context: []byte("world")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -150,7 +150,7 @@ func Test_StaticPool_JobError(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Body)
@@ -188,7 +188,7 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
}
}()
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.Error(t, err)
assert.Nil(t, res.Context)
@@ -212,7 +212,7 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
assert.NotNil(t, p)
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -290,11 +290,11 @@ func Test_StaticPool_Replace_Worker(t *testing.T) {
var lastPID string
lastPID = strconv.Itoa(int(p.Workers()[0].Pid()))
- res, _ := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, _ := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.Equal(t, lastPID, string(res.Body))
for i := 0; i < 10; i++ {
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -337,14 +337,14 @@ func Test_StaticPool_Stop_Worker(t *testing.T) {
var lastPID string
lastPID = strconv.Itoa(int(p.Workers()[0].Pid()))
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
if err != nil {
t.Fatal(err)
}
assert.Equal(t, lastPID, string(res.Body))
for i := 0; i < 10; i++ {
- res, err := p.Exec(ctx, Payload{Body: []byte("hello")})
+ res, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.NoError(t, err)
assert.NotNil(t, res)
@@ -375,7 +375,7 @@ func Test_Static_Pool_Destroy_And_Close(t *testing.T) {
assert.NoError(t, err)
p.Destroy(ctx)
- _, err = p.Exec(ctx, Payload{Body: []byte("100")})
+ _, err = p.ExecWithContext(ctx, Payload{Body: []byte("100")})
assert.Error(t, err)
}
@@ -398,7 +398,7 @@ func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) {
assert.NoError(t, err)
go func() {
- _, err := p.Exec(ctx, Payload{Body: []byte("100")})
+ _, err := p.ExecWithContext(ctx, Payload{Body: []byte("100")})
if err != nil {
t.Errorf("error executing payload: error %v", err)
}
@@ -406,7 +406,7 @@ func Test_Static_Pool_Destroy_And_Close_While_Wait(t *testing.T) {
time.Sleep(time.Millisecond * 10)
p.Destroy(ctx)
- _, err = p.Exec(ctx, Payload{Body: []byte("100")})
+ _, err = p.ExecWithContext(ctx, Payload{Body: []byte("100")})
assert.Error(t, err)
}
@@ -433,7 +433,7 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) {
w.State().Set(StateErrored)
}
- _, err = p.Exec(ctx, Payload{Body: []byte("hello")})
+ _, err = p.ExecWithContext(ctx, Payload{Body: []byte("hello")})
assert.Error(t, err)
}
@@ -472,7 +472,7 @@ func Benchmark_Pool_Echo(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
- if _, err := p.Exec(ctx, Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil {
b.Fail()
}
}
@@ -499,7 +499,7 @@ func Benchmark_Pool_Echo_Batched(b *testing.B) {
wg.Add(1)
go func() {
defer wg.Done()
- if _, err := p.Exec(ctx, Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil {
b.Fail()
log.Println(err)
}
@@ -529,7 +529,7 @@ func Benchmark_Pool_Echo_Replaced(b *testing.B) {
b.ReportAllocs()
for n := 0; n < b.N; n++ {
- if _, err := p.Exec(ctx, Payload{Body: []byte("hello")}); err != nil {
+ if _, err := p.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil {
b.Fail()
log.Println(err)
}