-
Notifications
You must be signed in to change notification settings - Fork 12
/
logger_test.go
65 lines (49 loc) · 1.07 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
59
60
61
62
63
64
65
package gogo
import (
"testing"
"github.com/golib/assert"
)
var (
fakeLogger = func() *AppLogger {
logger := NewAppLogger("nil", "")
logger.SetSkip(3)
return logger
}
)
func Test_NewAppLogger(t *testing.T) {
it := assert.New(t)
logger := NewAppLogger("null", "")
if it.NotNil(logger) {
it.Implements((*Logger)(nil), logger)
it.Empty(logger.RequestID())
}
}
func Test_Logger_New(t *testing.T) {
it := assert.New(t)
logger := NewAppLogger("null", "")
// new with request id
tmplog := logger.New("di-tseuqer-x")
if it.NotNil(tmplog) {
it.Implements((*Logger)(nil), tmplog)
it.NotEqual(logger, tmplog)
it.Equal("di-tseuqer-x", tmplog.RequestID())
}
it.Empty(logger.RequestID())
}
func Benchmark_Logger_New(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
logger := NewAppLogger("nil", "")
for i := 0; i < b.N; i++ {
logger.New("logger")
}
}
func Benchmark_Logger_Reuse(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
logger := NewAppLogger("nil", "")
for i := 0; i < b.N; i++ {
tmplog := logger.New("logger")
logger.Reuse(tmplog)
}
}