-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconsole_test.go
48 lines (37 loc) · 1.18 KB
/
console_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
package log
import (
"bytes"
"os"
. "gopkg.in/check.v1"
)
type WriterLoggerSuite struct {
}
var _ = Suite(&WriterLoggerSuite{})
func (s *WriterLoggerSuite) TestWriter(c *C) {
// INFO logger should log INFO, WARN and ERROR
l := &writerLogger{SeverityInfo, &bytes.Buffer{}}
c.Assert(l.Writer(SeverityInfo), NotNil)
c.Assert(l.Writer(SeverityWarning), NotNil)
c.Assert(l.Writer(SeverityError), NotNil)
// WARN logger should log WARN and ERROR
l = &writerLogger{SeverityWarning, &bytes.Buffer{}}
c.Assert(l.Writer(SeverityInfo), IsNil)
c.Assert(l.Writer(SeverityWarning), NotNil)
c.Assert(l.Writer(SeverityError), NotNil)
// ERROR logger should log only ERROR
l = &writerLogger{SeverityError, &bytes.Buffer{}}
c.Assert(l.Writer(SeverityInfo), IsNil)
c.Assert(l.Writer(SeverityWarning), IsNil)
c.Assert(l.Writer(SeverityError), NotNil)
}
type ConsoleLoggerSuite struct {
}
var _ = Suite(&ConsoleLoggerSuite{})
func (s *ConsoleLoggerSuite) TestNewConsoleLogger(c *C) {
l, err := NewConsoleLogger(Config{Console, "info"})
c.Assert(err, IsNil)
c.Assert(l, NotNil)
console := l.(*consoleLogger)
c.Assert(console.sev, Equals, SeverityInfo)
c.Assert(console.w, Equals, os.Stdout)
}