forked from fluxio/logging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem_logger_test.go
55 lines (50 loc) · 1.9 KB
/
mem_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
package logging
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestMemLogger(t *testing.T) {
Convey("MemLogger", t, func() {
memlogger := NewMemLogger()
Convey("Records trace message and level", func() {
memlogger.Trace("Bad News Bears")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{TraceLevel, "Bad News Bears"})
})
Convey("Records debug message and level", func() {
memlogger.Debug("Bad News Bears")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{DebugLevel, "Bad News Bears"})
})
Convey("Records info message and level", func() {
memlogger.Info("Bad News Bears")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{InfoLevel, "Bad News Bears"})
})
Convey("Records error message and level", func() {
memlogger.Error("Bad News Bears")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{ErrorLevel, "Bad News Bears"})
})
Convey("Records formatted trace message and level", func() {
memlogger.Tracef("Bad News Bears: %s", "Ruxbin")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{TraceLevel, "Bad News Bears: Ruxbin"})
})
Convey("Records formatted debug message and level", func() {
memlogger.Debugf("Bad News Bears: %s", "Ruxbin")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{DebugLevel, "Bad News Bears: Ruxbin"})
})
Convey("Records formatted info message and level", func() {
memlogger.Infof("Bad News Bears: %s", "Ruxbin")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{InfoLevel, "Bad News Bears: Ruxbin"})
})
Convey("Records formatted error message and level", func() {
memlogger.Errorf("Bad News Bears: %s", "Ruxbin")
msgs := memlogger.ExtractMsgs()
So(msgs[0], ShouldResemble, LogMessage{ErrorLevel, "Bad News Bears: Ruxbin"})
})
})
}