From f4c8a9d18c5b596f5311c64072252521820d284c Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 10 Nov 2021 12:23:56 +0300 Subject: [PATCH] test for change output Signed-off-by: Vasiliy Tolstov --- zerolog_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zerolog_test.go b/zerolog_test.go index cd6ac4c..346aad4 100644 --- a/zerolog_test.go +++ b/zerolog_test.go @@ -1,6 +1,7 @@ package zerolog import ( + "bytes" "context" "errors" "os" @@ -11,6 +12,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() l.Init()