-
Notifications
You must be signed in to change notification settings - Fork 18
/
console_test.go
51 lines (46 loc) · 1 KB
/
console_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 clog
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_consoleLogger(t *testing.T) {
testName := "Test_consoleLogger"
defer Remove(DefaultConsoleName)
defer Remove(testName)
tests := []struct {
name string
mode string
config interface{}
wantLevel Level
wantErr error
}{
{
name: "nil config",
mode: DefaultConsoleName,
wantErr: nil,
},
{
name: "valid config",
mode: DefaultConsoleName,
config: ConsoleConfig{
Level: LevelInfo,
},
wantErr: nil,
},
{
name: "custom name",
mode: testName,
wantErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assert.Equal(t, tt.wantErr, NewConsoleWithName(tt.mode, 10, tt.config))
})
}
assert.Equal(t, 2, mgr.len())
assert.Equal(t, DefaultConsoleName, mgr.loggers[0].Name())
assert.Equal(t, LevelInfo, mgr.loggers[0].Level())
assert.Equal(t, testName, mgr.loggers[1].Name())
assert.Equal(t, LevelTrace, mgr.loggers[1].Level())
}