This repository was archived by the owner on Feb 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathissue_test.go
More file actions
83 lines (69 loc) · 1.49 KB
/
issue_test.go
File metadata and controls
83 lines (69 loc) · 1.49 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package gomol
import (
"time"
"github.com/aphistic/sweet"
"github.com/efritz/glock"
. "github.com/onsi/gomega"
)
type IssueSuite struct{}
func (s *IssueSuite) TestIssue22(t sweet.T) {
clock := glock.NewMockClockAt(time.Unix(10, 0))
mlCfg := newMemLoggerConfig()
ml, err := newMemLogger(mlCfg)
Expect(err).To(BeNil())
Expect(ml).ToNot(BeNil())
base := NewBase(
withClock(clock),
)
base.AddLogger(ml)
err = base.InitLoggers()
Expect(err).To(BeNil())
defer base.ShutdownLoggers()
base.SetAttr("baseKey", 1234)
err = base.Dbgm(
NewAttrsFromMap(map[string]interface{}{
"mapKey": 1234,
}),
"Message 1",
)
Expect(err).To(BeNil())
base.Flush()
Expect(ml.Messages()).To(HaveLen(1))
Expect(ml.Messages()[0]).To(Equal(&memMessage{
Timestamp: clock.Now(),
Level: LevelDebug,
Message: "Message 1",
Attrs: map[string]interface{}{
"baseKey": 1234,
"mapKey": 1234,
},
StringAttrs: map[string]string{
"baseKey": "1234",
"mapKey": "1234",
},
}))
err = base.Dbgm(
NewAttrsFromMap(map[string]interface{}{
"mapFunc": func() int {
return 4321
},
}),
"Message 2",
)
Expect(err).To(BeNil())
base.Flush()
Expect(ml.Messages()).To(HaveLen(2))
Expect(ml.Messages()[1]).To(Equal(&memMessage{
Timestamp: clock.Now(),
Level: LevelDebug,
Message: "Message 2",
Attrs: map[string]interface{}{
"baseKey": 1234,
"mapFunc": "func() int",
},
StringAttrs: map[string]string{
"baseKey": "1234",
"mapFunc": "func() int",
},
}))
}