-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlog_level_setting_test.go
44 lines (34 loc) · 1.23 KB
/
log_level_setting_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
package log4g
import (
"github.com/dspasibenko/log4g/collections"
. "gopkg.in/check.v1"
"testing"
)
func Test(t *testing.T) { TestingT(t) }
type logLevelSettingSuite struct {
}
var _ = Suite(&logLevelSettingSuite{})
func (s *logLevelSettingSuite) TestSetLogLevel(c *C) {
ss, _ := collections.NewSortedSlice(2)
setLogLevel(INFO, "a.b", ss)
setLogLevel(INFO, "a", ss)
setLogLevel(INFO, "b", ss)
c.Assert(ss.Len(), Equals, 3)
c.Assert(ss.At(0).(*logLevelSetting).loggerName, Equals, "a")
c.Assert(ss.At(1).(*logLevelSetting).loggerName, Equals, "a.b")
c.Assert(ss.At(2).(*logLevelSetting).loggerName, Equals, "b")
}
func (s *logLevelSettingSuite) TestGetSetLogLevel(c *C) {
ss, _ := collections.NewSortedSlice(2)
c.Assert(getLogLevelSetting("a", ss), IsNil)
setLogLevel(INFO, "b", ss)
c.Assert(getLogLevelSetting("a", ss), IsNil)
setLogLevel(INFO, "", ss)
c.Assert(getLogLevelSetting("a", ss).loggerName, Equals, "")
setLogLevel(INFO, "b.d", ss)
setLogLevel(INFO, "b.d.e", ss)
setLogLevel(INFO, "b.d.e.g", ss)
c.Assert(getLogLevelSetting("b.d.a", ss).loggerName, Equals, "b.d")
c.Assert(getLogLevelSetting("b.d.e.f", ss).loggerName, Equals, "b.d.e")
c.Assert(getLogLevelSetting("b.d.e.g", ss).loggerName, Equals, "b.d.e.g")
}