-
Notifications
You must be signed in to change notification settings - Fork 3
/
level_test.go
51 lines (45 loc) · 1.51 KB
/
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
47
48
49
50
51
package logger_test
import (
"testing"
"github.com/gol4ng/logger"
"github.com/stretchr/testify/assert"
)
func TestLevelString_Level(t *testing.T) {
tests := []struct {
levelString logger.LevelString
expected logger.Level
}{
{levelString: "DEBUG", expected: logger.DebugLevel},
{levelString: "debug", expected: logger.DebugLevel},
{levelString: "info", expected: logger.InfoLevel},
{levelString: "notice", expected: logger.NoticeLevel},
{levelString: "warning", expected: logger.WarningLevel},
{levelString: "error", expected: logger.ErrorLevel},
{levelString: "critical", expected: logger.CriticalLevel},
{levelString: "alert", expected: logger.AlertLevel},
{levelString: "emergency", expected: logger.EmergencyLevel},
{levelString: "anothervalue", expected: logger.DebugLevel},
}
for _, tt := range tests {
assert.Equal(t, tt.expected, tt.levelString.Level())
}
}
func TestLevel_String(t *testing.T) {
tests := []struct {
level logger.Level
expected string
}{
{level: logger.DebugLevel, expected: "debug"},
{level: logger.InfoLevel, expected: "info"},
{level: logger.NoticeLevel, expected: "notice"},
{level: logger.WarningLevel, expected: "warning"},
{level: logger.ErrorLevel, expected: "error"},
{level: logger.CriticalLevel, expected: "critical"},
{level: logger.AlertLevel, expected: "alert"},
{level: logger.EmergencyLevel, expected: "emergency"},
{level: 123, expected: "level(123)"},
}
for _, tt := range tests {
assert.Equal(t, tt.expected, tt.level.String())
}
}