summaryrefslogtreecommitdiff
path: root/static_pool_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2019-11-17 15:32:26 +0300
committerValery Piashchynski <[email protected]>2019-11-17 15:32:26 +0300
commit492faef8e51fce243216758baa8c16b4173603df (patch)
treeda6376fba9a9af3358017dcbd5034677192f407b /static_pool_test.go
parentb81f2b121eb3a49372662d0bc9c19c53366f33fc (diff)
complete half
Diffstat (limited to 'static_pool_test.go')
-rw-r--r--static_pool_test.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/static_pool_test.go b/static_pool_test.go
index a7e71fdb..f5313f6b 100644
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -23,12 +23,13 @@ func Test_NewPool(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
+
assert.Equal(t, cfg, p.Config())
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
}
func Test_StaticPool_Invalid(t *testing.T) {
@@ -62,10 +63,11 @@ func Test_StaticPool_Echo(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
+
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
res, err := p.Exec(&Payload{Body: []byte("hello")})
@@ -83,10 +85,11 @@ func Test_StaticPool_Echo_NilContext(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
+
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
res, err := p.Exec(&Payload{Body: []byte("hello"), Context: nil})
@@ -104,10 +107,11 @@ func Test_StaticPool_Echo_Context(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
+
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
res, err := p.Exec(&Payload{Body: []byte("hello"), Context: []byte("world")})
@@ -125,10 +129,10 @@ func Test_StaticPool_JobError(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
res, err := p.Exec(&Payload{Body: []byte("hello")})
@@ -145,10 +149,10 @@ func Test_StaticPool_Broken_Replace(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
p.Listen(func(e int, ctx interface{}) {
if err, ok := ctx.(error); ok {
@@ -168,10 +172,10 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
NewPipeFactory(),
cfg,
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
res, err := p.Exec(&Payload{Body: []byte("hello")})
@@ -192,7 +196,10 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
// killing random worker and expecting pool to replace it
p.muw.Lock()
- p.workers[0].cmd.Process.Kill()
+ err = p.Workers()[0].cmd.Process.Kill()
+ if err != nil {
+ t.Errorf("error killing the process: error %v", err)
+ }
p.muw.Unlock()
<-destructed
@@ -244,10 +251,10 @@ func Test_StaticPool_Replace_Worker(t *testing.T) {
DestroyTimeout: time.Second,
},
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
var lastPID string
lastPID = strconv.Itoa(*p.Workers()[0].Pid)
@@ -279,10 +286,10 @@ func Test_StaticPool_Stop_Worker(t *testing.T) {
DestroyTimeout: time.Second,
},
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
var lastPID string
lastPID = strconv.Itoa(*p.Workers()[0].Pid)
@@ -357,10 +364,10 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) {
DestroyTimeout: time.Second,
},
)
+ assert.NoError(t, err)
defer p.Destroy()
assert.NotNil(t, p)
- assert.NoError(t, err)
for _, w := range p.workers {
w.state.value = StateErrored