From 642b681c2a9be27791e36e1c2d2766625fb0eceb Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 10 Nov 2021 12:32:19 +0300 Subject: [PATCH] test for change output Signed-off-by: Vasiliy Tolstov --- logrus_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/logrus_test.go b/logrus_test.go index 6aa4953..fdfd105 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -1,6 +1,7 @@ package logrus import ( + "bytes" "context" "errors" "os" @@ -10,6 +11,18 @@ import ( "go.unistack.org/micro/v3/logger" ) +func TestOutput(t *testing.T) { + buf := bytes.NewBuffer(nil) + l := NewLogger(logger.WithOutput(buf)) + if err := l.Init(); err != nil { + t.Fatal(err) + } + l.Infof(context.TODO(), "test logger name: %s", "name") + if !bytes.Contains(buf.Bytes(), []byte(`test logger name`)) { + t.Fatalf("log not redirected: %s", buf.Bytes()) + } +} + func TestName(t *testing.T) { l := NewLogger() if err := l.Init(); err != nil {