bsc/log/async_file_writer_test.go

27 lines
430 B
Go
Raw Normal View History

2020-05-20 06:47:42 +03:00
package log
import (
"io/ioutil"
"os"
"strings"
"testing"
)
func TestWriter(t *testing.T) {
w := NewAsyncFileWriter("./hello.log", 100)
w.Start()
w.Write([]byte("hello\n"))
w.Write([]byte("world\n"))
w.Stop()
files, _ := ioutil.ReadDir("./")
for _, f := range files {
fn := f.Name()
if strings.HasPrefix(fn, "hello") {
t.Log(fn)
content, _ := ioutil.ReadFile(fn)
t.Log(content)
os.Remove(fn)
}
}
}