summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--error_buffer_test.go14
-rw-r--r--errors_test.go6
-rw-r--r--server_config.go2
-rw-r--r--static_pool_test.go4
-rw-r--r--worker.go5
5 files changed, 24 insertions, 7 deletions
diff --git a/error_buffer_test.go b/error_buffer_test.go
new file mode 100644
index 00000000..ce252612
--- /dev/null
+++ b/error_buffer_test.go
@@ -0,0 +1,14 @@
+package roadrunner
+
+import (
+ "testing"
+ "bytes"
+ "github.com/magiconair/properties/assert"
+)
+
+func TestErrBuffer_Write_Len(t *testing.T) {
+ buf := &errBuffer{buffer: new(bytes.Buffer)}
+ buf.Write([]byte("hello"))
+ assert.Equal(t, 5, buf.Len())
+ assert.Equal(t, buf.String(), "hello")
+}
diff --git a/errors_test.go b/errors_test.go
index 9b0fa53e..d7b2feb4 100644
--- a/errors_test.go
+++ b/errors_test.go
@@ -3,9 +3,15 @@ package roadrunner
import (
"github.com/stretchr/testify/assert"
"testing"
+ "github.com/go-errors/errors"
)
func Test_JobError_Error(t *testing.T) {
e := JobError([]byte("error"))
assert.Equal(t, "error", e.Error())
}
+
+func Test_WorkerError_Error(t *testing.T) {
+ e := WorkerError{Worker: nil, Caused: errors.New("error")}
+ assert.Equal(t, "error", e.Error())
+}
diff --git a/server_config.go b/server_config.go
index 7e0dcbe9..37f3359b 100644
--- a/server_config.go
+++ b/server_config.go
@@ -8,7 +8,7 @@ import (
)
const (
- FactoryPipes = iota
+ FactoryPipes = iota
FactorySocket
)
diff --git a/static_pool_test.go b/static_pool_test.go
index 5fe7e062..b7e5b0dd 100644
--- a/static_pool_test.go
+++ b/static_pool_test.go
@@ -185,10 +185,6 @@ func Test_StaticPool_Broken_FromOutside(t *testing.T) {
destructed := make(chan interface{})
p.Observe(func(e int, ctx interface{}) {
- if err, ok := ctx.(error); ok {
- assert.Contains(t, err.Error(), "exit status 1")
- }
-
if e == EventWorkerCreate {
close(destructed)
}
diff --git a/worker.go b/worker.go
index e33ea327..c7fe136a 100644
--- a/worker.go
+++ b/worker.go
@@ -203,9 +203,10 @@ func (w *Worker) start() error {
w.endState, _ = w.cmd.Process.Wait()
if w.waitDone != nil {
close(w.waitDone)
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
if w.rl != nil {
- w.mu.Lock()
- defer w.mu.Unlock()
w.rl.Close()
}
}