forked from morita-kuma/golog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loglevelfilter_test.go
83 lines (74 loc) · 1.21 KB
/
loglevelfilter_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
74
75
76
77
78
79
80
81
82
83
package golog
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewLogLevelFilter(t *testing.T) {
cases := []struct {
input LogLevel
expected LogLevels
} {
// trace
{
input: LogLevel_TRACE,
expected: LogLevels {
LogLevel_TRACE,
LogLevel_DEBUG,
LogLevel_INFO,
LogLevel_WARN,
LogLevel_ERROR,
LogLevel_FATAL,
},
},
// debug
{
input: LogLevel_DEBUG,
expected: LogLevels {
LogLevel_DEBUG,
LogLevel_INFO,
LogLevel_WARN,
LogLevel_ERROR,
LogLevel_FATAL,
},
},
// info
{
input: LogLevel_INFO,
expected: LogLevels {
LogLevel_INFO,
LogLevel_WARN,
LogLevel_ERROR,
LogLevel_FATAL,
},
},
// warn
{
input: LogLevel_WARN,
expected: LogLevels {
LogLevel_WARN,
LogLevel_ERROR,
LogLevel_FATAL,
},
},
// error
{
input: LogLevel_ERROR,
expected: LogLevels {
LogLevel_ERROR,
LogLevel_FATAL,
},
},
// fatal
{
input: LogLevel_FATAL,
expected: LogLevels {
LogLevel_FATAL,
},
},
}
for _, c := range cases {
logLevelFilter := NewDefaultLevelFilter()
actual := logLevelFilter.DoFilter(c.input)
assert.Equal(t, actual.SortAsc(), c.expected.SortAsc())
}
}