-
Notifications
You must be signed in to change notification settings - Fork 4
/
logger_test.go
40 lines (35 loc) · 929 Bytes
/
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
package golog_test
import (
"testing"
. "github.com/damianopetrungaro/golog"
)
func TestNoopCheckedLogger_Log(t *testing.T) {
checkedLogger := &NoopCheckedLogger{}
checkedLogger.Log(String("test", "noop"))
}
func TestStdCheckedLogger_Log(t *testing.T) {
t.Run("fatal entry", func(t *testing.T) {
flds := Fields{Bool("key", true)}
var e Entry = fatalEntry
w := &FakeWriter{}
defer func() {
EntryMatcher(t, w.Entry, e.With(flds...))
}()
defer func() {
// nolint:staticcheck
if r := recover(); r != nil {
}
}()
checkedLogger := &StdCheckedLogger{Entry: fatalEntry, Writer: w}
checkedLogger.Log(flds...)
})
t.Run("non fatal entry", func(t *testing.T) {
flds := Fields{Bool("key", true)}
w := &FakeWriter{}
var e Entry = debugEntry
e = e.With(flds...)
checkedLogger := &StdCheckedLogger{Entry: debugEntry, Writer: w}
checkedLogger.Log(flds...)
EntryMatcher(t, w.Entry, e)
})
}