summaryrefslogtreecommitdiff
path: root/error_buffer_test.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-23 19:04:50 +0300
committerWolfy-J <[email protected]>2018-06-23 19:04:50 +0300
commit008a42fc6138e74766cdf9011a8dfc60df71b4a0 (patch)
treecdf85cb5536c8416020ca21475751dae0b9117a0 /error_buffer_test.go
parent918e7de39e16eb293567427f2e8e8c3035690163 (diff)
error aggregation
Diffstat (limited to 'error_buffer_test.go')
-rw-r--r--error_buffer_test.go20
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"))