logger: add logger Fields test #75

Merged
vtolstov merged 1 commits from logger_test into master 2022-01-20 00:31:23 +03:00
Showing only changes of commit dfd85cd871 - Show all commits

View File

@ -7,6 +7,19 @@ import (
"testing" "testing"
) )
func TestFields(t *testing.T) {
ctx := context.TODO()
buf := bytes.NewBuffer(nil)
l := NewLogger(WithLevel(TraceLevel), WithOutput(buf))
if err := l.Init(); err != nil {
t.Fatal(err)
}
l.Fields("key", "val").Info(ctx, "message")
if !bytes.Contains(buf.Bytes(), []byte(`"key":"val"`)) {
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
}
}
func TestClone(t *testing.T) { func TestClone(t *testing.T) {
ctx := context.TODO() ctx := context.TODO()
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)