-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger_test.go
73 lines (69 loc) · 1.64 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
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/zap/zapcore"
)
func TestLoggerConfigure(t *testing.T) {
tests := []struct {
options *Options
wantLoggerLevel zapcore.Level
}{
{
options: &Options{Verbosity: []bool{}},
wantLoggerLevel: zapcore.WarnLevel,
},
{
options: &Options{Verbosity: []bool{true}},
wantLoggerLevel: zapcore.InfoLevel,
},
{
options: &Options{Verbosity: []bool{true, true}},
wantLoggerLevel: zapcore.DebugLevel,
},
{
options: &Options{Verbosity: []bool{true, true, true}},
wantLoggerLevel: zapcore.DebugLevel,
},
{
options: &Options{Verbosity: []bool{false}},
wantLoggerLevel: zapcore.InfoLevel,
},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("Test logger: %v", tt.wantLoggerLevel), func(t *testing.T) {
lconf := configureLoggerConfig(tt.options)
assert.Equal(t, lconf.Level.Level(), tt.wantLoggerLevel)
})
}
}
func TestLoggerGetLoggerVerbosity(t *testing.T) {
tests := []struct {
verbosity []bool
wantLoggerLevel zapcore.Level
}{
{
verbosity: nil,
wantLoggerLevel: zapcore.WarnLevel,
},
{
verbosity: []bool{true},
wantLoggerLevel: zapcore.InfoLevel,
},
{
verbosity: []bool{true, true},
wantLoggerLevel: zapcore.DebugLevel,
},
{
verbosity: []bool{true, true, true},
wantLoggerLevel: zapcore.DebugLevel,
},
}
for _, tt := range tests {
t.Run(fmt.Sprintf("getLoggerVerbosity(%v)", tt.verbosity), func(t *testing.T) {
lvl := getLoggerVerbosity(tt.verbosity)
assert.Equal(t, lvl, tt.wantLoggerLevel)
})
}
}