-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlogger_test.go
58 lines (43 loc) · 1.18 KB
/
logger_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
56
57
58
package chromelogger
import (
"testing"
"path/filepath"
"strings"
assert "github.com/pilu/miniassert"
)
func TestLogger_Add(t *testing.T) {
logger := newLogger()
assert.Equal(t, 0, len(logger.data.Rows))
logger.add("foo", "log")
assert.Equal(t, 1, len(logger.data.Rows))
}
func TestLogger_Log(t *testing.T) {
logger := newLogger()
assert.Equal(t, 0, len(logger.data.Rows))
logger.Log("foo")
assert.Equal(t, 1, len(logger.data.Rows))
row := logger.data.Rows[0]
backtracePath := (*row)[1].(string)
backtraceFilenameAndLine := filepath.Base(backtracePath)
backtraceChunks := strings.Split(backtraceFilenameAndLine, ":")
assert.Equal(t, "logger_test.go", backtraceChunks[0])
assert.Equal(t, "log", (*row)[2])
}
func TestLogger_Warn(t *testing.T) {
logger := newLogger()
logger.Warn("foo")
row := logger.data.Rows[0]
assert.Equal(t, "warn", (*row)[2])
}
func TestLogger_Error(t *testing.T) {
logger := newLogger()
logger.Error("foo")
row := logger.data.Rows[0]
assert.Equal(t, "error", (*row)[2])
}
func TestLogger_Info(t *testing.T) {
logger := newLogger()
logger.Info("foo")
row := logger.data.Rows[0]
assert.Equal(t, "info", (*row)[2])
}