forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_test.go
46 lines (42 loc) · 920 Bytes
/
log_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
package astiav_test
import (
"testing"
"github.com/asticode/go-astiav"
"github.com/stretchr/testify/require"
)
type logItem struct {
l astiav.LogLevel
msg string
}
func TestLog(t *testing.T) {
var lis []logItem
astiav.SetLogCallback(func(l astiav.LogLevel, msg, parent string) {
lis = append(lis, logItem{
l: l,
msg: msg,
})
})
astiav.SetLogLevel(astiav.LogLevelWarning)
astiav.Log(astiav.LogLevelInfo, "info")
astiav.Log(astiav.LogLevelWarning, "warning")
astiav.Log(astiav.LogLevelError, "error")
astiav.Log(astiav.LogLevelFatal, "fatal")
require.Equal(t, []logItem{
{
l: astiav.LogLevelWarning,
msg: "warning",
},
{
l: astiav.LogLevelError,
msg: "error",
},
{
l: astiav.LogLevelFatal,
msg: "fatal",
},
}, lis)
astiav.ResetLogCallback()
lis = []logItem{}
astiav.Log(astiav.LogLevelError, "test error log\n")
require.Equal(t, []logItem{}, lis)
}