-
Notifications
You must be signed in to change notification settings - Fork 10
/
logger_test.go
61 lines (57 loc) · 1.39 KB
/
logger_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package svc
import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func TestNewLogger(t *testing.T) {
tests := []struct {
name string
serviceOption Option
}{
{
name: "console logger",
serviceOption: WithConsoleLogger(zap.InfoLevel),
},
{
name: "console logger with options",
serviceOption: WithConsoleLogger(zap.DebugLevel, zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return core
})),
},
{
name: "development logger",
serviceOption: WithDevelopmentLogger(),
},
{
name: "development logger with options",
serviceOption: WithDevelopmentLogger(zap.Development()),
},
{
name: "production logger",
serviceOption: WithProductionLogger(),
},
{
name: "production logger with options",
serviceOption: WithProductionLogger(zap.WithCaller(true)),
},
{
name: "stackdriver logger",
serviceOption: WithStackdriverLogger(zap.WarnLevel),
},
{
name: "stackdriver logger with options",
serviceOption: WithStackdriverLogger(zap.WarnLevel, zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return core
}), zap.AddCaller()),
},
}
for _, tt := range tests {
tc := tt
t.Run(tc.name, func(t *testing.T) {
_, err := New("dummy-name", "dummy-version", tc.serviceOption)
require.NoError(t, err)
})
}
}