|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+package logger_test
|
|
|
2
|
+
|
|
|
3
|
+import (
|
|
|
4
|
+ "io"
|
|
|
5
|
+ "testing"
|
|
|
6
|
+
|
|
|
7
|
+ "github.com/9seconds/mtg/v2/logger"
|
|
|
8
|
+ "github.com/9seconds/mtg/v2/testlib"
|
|
|
9
|
+ "github.com/stretchr/testify/suite"
|
|
|
10
|
+)
|
|
|
11
|
+
|
|
|
12
|
+type NoopLoggerTestSuite struct {
|
|
|
13
|
+ suite.Suite
|
|
|
14
|
+}
|
|
|
15
|
+
|
|
|
16
|
+func (suite *NoopLoggerTestSuite) TestLog() {
|
|
|
17
|
+ suite.Empty(testlib.CaptureStdout(func() {
|
|
|
18
|
+ suite.Empty(testlib.CaptureStderr(func() {
|
|
|
19
|
+ log := logger.NewNoopLogger().Named("name")
|
|
|
20
|
+
|
|
|
21
|
+ log.BindInt("int", 1).BindStr("str", "1").Info("info")
|
|
|
22
|
+ log.BindInt("int", 1).BindStr("str", "1").Warning("info")
|
|
|
23
|
+ log.BindInt("int", 1).BindStr("str", "1").Debug("info")
|
|
|
24
|
+ log.BindInt("int", 1).BindStr("str", "1").InfoError("info", io.EOF)
|
|
|
25
|
+ log.BindInt("int", 1).BindStr("str", "1").WarningError("info", io.EOF)
|
|
|
26
|
+ log.BindInt("int", 1).BindStr("str", "1").DebugError("info", io.EOF)
|
|
|
27
|
+ }))
|
|
|
28
|
+ }))
|
|
|
29
|
+}
|
|
|
30
|
+
|
|
|
31
|
+func TestNoopLogger(t *testing.T) {
|
|
|
32
|
+ t.Parallel()
|
|
|
33
|
+ suite.Run(t, &NoopLoggerTestSuite{})
|
|
|
34
|
+}
|