-
Notifications
You must be signed in to change notification settings - Fork 0
/
levels_test.go
78 lines (74 loc) · 1.52 KB
/
levels_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
package clog_test
import (
"fmt"
"log/slog"
"testing"
"github.com/ronny/clog"
"github.com/stretchr/testify/assert"
)
func TestLevelName(t *testing.T) {
testCases := []struct {
desc string
level slog.Level
expected string
}{
{
desc: "clog.LevelDefault -> DEFAULT",
level: clog.LevelDefault,
expected: "DEFAULT",
},
{
desc: "clog.LevelDebug -> DEBUG",
level: clog.LevelDebug,
expected: "DEBUG",
},
{
desc: "clog.LevelInfo -> INFO",
level: clog.LevelInfo,
expected: "INFO",
},
{
desc: "clog.LevelNotice -> NOTICE",
level: clog.LevelNotice,
expected: "NOTICE",
},
{
desc: "clog.LevelWarning -> WARNING",
level: clog.LevelWarning,
expected: "WARNING",
},
{
desc: "slog.LevelWarn -> WARNING", // ⚠️ Warn vs Warning
level: slog.LevelWarn,
expected: "WARNING",
},
{
desc: "clog.LevelError -> ERROR",
level: clog.LevelError,
expected: "ERROR",
},
{
desc: "clog.LevelCritical -> CRITICAL",
level: clog.LevelCritical,
expected: "CRITICAL",
},
{
desc: "clog.LevelAlert -> ALERT",
level: clog.LevelAlert,
expected: "ALERT",
},
{
desc: "clog.LevelEmergency -> EMERGENCY",
level: clog.LevelEmergency,
expected: "EMERGENCY",
},
}
for i, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("%d: %s", i, tc.desc), func(t *testing.T) {
t.Parallel()
actual := clog.LevelName(tc.level)
assert.Equal(t, tc.expected, actual)
})
}
}