-
Notifications
You must be signed in to change notification settings - Fork 0
/
level_test.go
46 lines (41 loc) · 955 Bytes
/
level_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
package logger
import (
"testing"
"github.com/sirupsen/logrus"
)
func TestMapLevelToLogrusLevel(t *testing.T) {
type testCase struct {
input Level
expectedOutput logrus.Level
}
testCases := map[string]testCase{
"map LevelFatal": {
input: LevelFatal,
expectedOutput: logrus.FatalLevel,
},
"map LevelError": {
input: LevelError,
expectedOutput: logrus.ErrorLevel,
},
"map LevelWarn": {
input: LevelWarn,
expectedOutput: logrus.WarnLevel,
},
"map LevelInfo": {
input: LevelInfo,
expectedOutput: logrus.InfoLevel,
},
"map levelDebug": {
input: LevelDebug,
expectedOutput: logrus.DebugLevel,
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
res := mapLevelToLogrusLevel(tc.input)
if res != tc.expectedOutput {
t.Fatalf("expected %v to map to %v, got: %v", tc.input, tc.expectedOutput, res)
}
})
}
}