2020-04-29 20:51:32 +00:00
|
|
|
package logger
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2020-07-23 23:36:31 +00:00
|
|
|
type outputFunc func(b []byte)
|
|
|
|
|
|
|
|
func (f outputFunc) WriteLogLine(data []byte) {
|
|
|
|
f(data)
|
|
|
|
}
|
|
|
|
|
2020-04-29 20:51:32 +00:00
|
|
|
func TestWriteManger(t *testing.T) {
|
|
|
|
testData := []byte(string("hello Austin, how are you doing?"))
|
|
|
|
waitChan := make(chan []byte)
|
|
|
|
m := NewWriteManager()
|
2020-07-23 23:36:31 +00:00
|
|
|
m.Append(testData, outputFunc(func(b []byte) {
|
2020-04-29 20:51:32 +00:00
|
|
|
waitChan <- b
|
2020-07-23 23:36:31 +00:00
|
|
|
}))
|
2020-04-29 20:51:32 +00:00
|
|
|
resp := <-waitChan
|
|
|
|
assert.Equal(t, testData, resp)
|
|
|
|
}
|