-
Notifications
You must be signed in to change notification settings - Fork 1
/
loglevel_test.go
55 lines (51 loc) · 1.11 KB
/
loglevel_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
package slog
import (
"testing"
)
func TestGetDescription(t *testing.T) {
var LA LogLevel = "LA"
testCases := []struct {
name string
level LogLevel
expectedDescription string
}{
{
name: "input is INFO",
level: INFO,
expectedDescription: "info",
},
{
name: "input is WARN",
level: WARN,
expectedDescription: "warn",
},
{
name: "input is ERROR",
level: ERROR,
expectedDescription: "error",
},
{
name: "input is FATAL",
level: FATAL,
expectedDescription: "fatal",
},
{
name: "input is DEBUG",
level: DEBUG,
expectedDescription: "debug",
},
{
name: "input with no description",
level: LA,
expectedDescription: "LA",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
result := getDescription(tc.level)
if result != tc.expectedDescription {
t.Errorf("Got %q want %q.", result, tc.expectedDescription)
}
})
}
}