blob: aa6a17f211eb7d7061eae5c40b736777f89936ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package roadrunner
import (
"bytes"
"github.com/stretchr/testify/assert"
"testing"
)
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")
}
func TestErrBuffer_Write_Event(t *testing.T) {
buf := &errBuffer{buffer: new(bytes.Buffer)}
tr := make(chan interface{})
buf.Listen(func(event int, ctx interface{}) {
assert.Equal(t, EventStderrOutput, event)
assert.Equal(t, []byte("hello"), ctx)
close(tr)
})
buf.Write([]byte("hello"))
<-tr
assert.Equal(t, 5, buf.Len())
assert.Equal(t, buf.String(), "hello")
}
|