-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathspec_test.go
More file actions
52 lines (48 loc) · 1.02 KB
/
spec_test.go
File metadata and controls
52 lines (48 loc) · 1.02 KB
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
package logging
import (
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/zap/zapcore"
)
func TestSortedEntriesFromEnv(t *testing.T) {
tests := []struct {
name string
in func(string) string
expected []*levelSpec
}{
{
"standard",
fakeEnv(map[string]string{
"DEBUG": "true",
}),
[]*levelSpec{
{key: "true", level: zapcore.DebugLevel, trace: false, ordering: 1},
},
},
{
"debug=true and trace=true",
fakeEnv(map[string]string{
"DEBUG": "true",
"TRACE": "true",
}),
[]*levelSpec{
{key: "true", level: zapcore.DebugLevel, trace: false, ordering: 1},
{key: "true", level: zapcore.DebugLevel, trace: true, ordering: 2},
},
},
{
"trace=*",
fakeEnv(map[string]string{
"TRACE": "*",
}),
[]*levelSpec{
{key: "*", level: zapcore.DebugLevel, trace: true, ordering: 1},
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.expected, newLogLevelSpec(test.in).sortedSpecs())
})
}
}