-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gorm_test.go
54 lines (40 loc) · 963 Bytes
/
gorm_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
package logger
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGormNewLogger(t *testing.T) {
t.Parallel()
t.Run("basic logger", func(t *testing.T) {
l := NewGormLogger(true, 3)
require.NotNil(t, l)
l = NewGormLogger(false, 3)
require.NotNil(t, l)
})
}
func TestBasicLogger_LogMode(t *testing.T) {
t.Parallel()
t.Run("new mode", func(t *testing.T) {
l := NewGormLogger(true, 3)
require.NotNil(t, l)
l2 := l.SetMode(Info)
require.NotNil(t, l2)
mode := l.GetMode()
assert.Equal(t, Info, mode)
})
}
func TestBasicLogger_SetStackLevel(t *testing.T) {
t.Parallel()
t.Run("set/get level", func(t *testing.T) {
l := NewGormLogger(true, 3)
require.NotNil(t, l)
l.SetStackLevel(3)
level := l.GetStackLevel()
assert.Equal(t, 3, level)
})
}
func TestFileWithLineNum(t *testing.T) {
str := fileWithLineNum()
assert.Contains(t, str, "src/testing/testing.go:")
}