diff options
Diffstat (limited to 'error_buffer_test.go')
-rw-r--r-- | error_buffer_test.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/error_buffer_test.go b/error_buffer_test.go index 2bf98915..09ea4f03 100644 --- a/error_buffer_test.go +++ b/error_buffer_test.go @@ -7,6 +7,7 @@ import ( func TestErrBuffer_Write_Len(t *testing.T) { buf := newErrBuffer() + defer buf.Close() buf.Write([]byte("hello")) assert.Equal(t, 5, buf.Len()) @@ -15,44 +16,47 @@ func TestErrBuffer_Write_Len(t *testing.T) { func TestErrBuffer_Write_Event(t *testing.T) { buf := newErrBuffer() + defer buf.Close() tr := make(chan interface{}) buf.Listen(func(event int, ctx interface{}) { assert.Equal(t, EventStderrOutput, event) - assert.Equal(t, []byte("hello\n\n"), ctx) + assert.Equal(t, []byte("hello\n"), ctx) close(tr) }) - buf.Write([]byte("hello\n\n")) + buf.Write([]byte("hello\n")) <-tr // messages are read - assert.Equal(t, 0, buf.Len()) - assert.Equal(t, "", buf.String()) + assert.Equal(t, 6, buf.Len()) + assert.Equal(t, "hello\n", buf.String()) } func TestErrBuffer_Write_Event_Separated(t *testing.T) { buf := newErrBuffer() + defer buf.Close() tr := make(chan interface{}) buf.Listen(func(event int, ctx interface{}) { assert.Equal(t, EventStderrOutput, event) - assert.Equal(t, []byte("hello\n\n"), ctx) + assert.Equal(t, []byte("hello\nending"), ctx) close(tr) }) buf.Write([]byte("hel")) - buf.Write([]byte("lo\n\n")) + buf.Write([]byte("lo\n")) buf.Write([]byte("ending")) <-tr - assert.Equal(t, 6, buf.Len()) - assert.Equal(t, "ending", buf.String()) + assert.Equal(t, 12, buf.Len()) + assert.Equal(t, "hello\nending", buf.String()) } func TestErrBuffer_Write_Remaining(t *testing.T) { buf := newErrBuffer() + defer buf.Close() buf.Write([]byte("hel")) |