restore v0.3.0
This commit is contained in:
36
handler/logrus/logger_test.go
Normal file
36
handler/logrus/logger_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package logrus_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
lgr "github.com/sirupsen/logrus"
|
||||
"gitoa.ru/go-4devs/log/entry"
|
||||
"gitoa.ru/go-4devs/log/handler/logrus"
|
||||
"gitoa.ru/go-4devs/log/level"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
buf := &bytes.Buffer{}
|
||||
|
||||
lgrus := lgr.New()
|
||||
lgrus.SetLevel(lgr.DebugLevel)
|
||||
lgrus.SetOutput(buf)
|
||||
lgrus.SetFormatter(&lgr.TextFormatter{
|
||||
DisableTimestamp: true,
|
||||
})
|
||||
|
||||
handler := logrus.New(logrus.WithLogrus(lgrus))
|
||||
expect := "level=info msg=\"handle logrus message\"\n"
|
||||
|
||||
if _, err := handler(ctx, entry.New(entry.WithLevel(level.Info), entry.WithMessage("handle logrus message"))); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if !strings.HasSuffix(buf.String(), expect) {
|
||||
t.Errorf("invalid suffix\n got: %s\nexpect:%s\n", buf.String(), expect)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user