summaryrefslogtreecommitdiff
path: root/error_buffer_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
committerValery Piashchynski <[email protected]>2020-10-13 13:55:20 +0300
commit0dc44d54cfcc9dd3fa09a41136f35a9a8d26b994 (patch)
treeffcb65010bebe9f5b5436192979e64b2402a6ec0 /error_buffer_test.go
parent08d6b6b7f773f83b286cd48c1a0fbec9a62fb42b (diff)
Initial commit of RR 2.0v2.0.0-alpha1
Diffstat (limited to 'error_buffer_test.go')
-rw-r--r--error_buffer_test.go131
1 files changed, 0 insertions, 131 deletions
diff --git a/error_buffer_test.go b/error_buffer_test.go
deleted file mode 100644
index c163ea43..00000000
--- a/error_buffer_test.go
+++ /dev/null
@@ -1,131 +0,0 @@
-package roadrunner
-
-import (
- "github.com/stretchr/testify/assert"
- "testing"
-)
-
-func TestErrBuffer_Write_Len(t *testing.T) {
- buf := newErrBuffer()
- defer func() {
- err := buf.Close()
- if err != nil {
- t.Errorf("error during closing the buffer: error %v", err)
- }
- }()
-
- _, err := buf.Write([]byte("hello"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
- assert.Equal(t, 5, buf.Len())
- assert.Equal(t, "hello", buf.String())
-}
-
-func TestErrBuffer_Write_Event(t *testing.T) {
- buf := newErrBuffer()
- defer func() {
- err := buf.Close()
- if err != nil {
- t.Errorf("error during closing the buffer: error %v", err)
- }
- }()
-
- tr := make(chan interface{})
- buf.Listen(func(event int, ctx interface{}) {
- assert.Equal(t, EventStderrOutput, event)
- assert.Equal(t, []byte("hello\n"), ctx)
- close(tr)
- })
-
- _, err := buf.Write([]byte("hello\n"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
- <-tr
-
- // messages are read
- assert.Equal(t, 0, buf.Len())
-}
-
-func TestErrBuffer_Write_Event_Separated(t *testing.T) {
- buf := newErrBuffer()
- defer func() {
- err := buf.Close()
- if err != nil {
- t.Errorf("error during closing the buffer: error %v", err)
- }
- }()
-
- tr := make(chan interface{})
- buf.Listen(func(event int, ctx interface{}) {
- assert.Equal(t, EventStderrOutput, event)
- assert.Equal(t, []byte("hello\nending"), ctx)
- close(tr)
- })
-
- _, err := buf.Write([]byte("hel"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- _, err = buf.Write([]byte("lo\n"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- _, err = buf.Write([]byte("ending"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- <-tr
- assert.Equal(t, 0, buf.Len())
- assert.Equal(t, "", buf.String())
-}
-
-func TestErrBuffer_Write_Event_Separated_NoListener(t *testing.T) {
- buf := newErrBuffer()
- defer func() {
- err := buf.Close()
- if err != nil {
- t.Errorf("error during closing the buffer: error %v", err)
- }
- }()
-
- _, err := buf.Write([]byte("hel"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- _, err = buf.Write([]byte("lo\n"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- _, err = buf.Write([]byte("ending"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- assert.Equal(t, 12, buf.Len())
- assert.Equal(t, "hello\nending", buf.String())
-}
-
-func TestErrBuffer_Write_Remaining(t *testing.T) {
- buf := newErrBuffer()
- defer func() {
- err := buf.Close()
- if err != nil {
- t.Errorf("error during closing the buffer: error %v", err)
- }
- }()
-
- _, err := buf.Write([]byte("hel"))
- if err != nil {
- t.Errorf("fail to write: error %v", err)
- }
-
- assert.Equal(t, 3, buf.Len())
- assert.Equal(t, "hel", buf.String())
-}