-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathfilehandler_test.go
More file actions
36 lines (30 loc) · 931 Bytes
/
filehandler_test.go
File metadata and controls
36 lines (30 loc) · 931 Bytes
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
package syslog
import (
"testing"
"time"
)
type TestLogger struct{}
func (tl TestLogger) Print(...interface{}) {}
func (tl TestLogger) Printf(format string, v ...interface{}) {}
func (tl TestLogger) Println(...interface{}) {}
func TestNewFileHandler(t *testing.T) {
fh := NewFileHandler("", 1, func(m *Message) bool { return true }, true)
if fh == nil {
t.Errorf("expected filehandler, got nil")
}
}
func TestSetLogger(t *testing.T) {
tl := TestLogger{}
fh := NewFileHandler("", 1, func(m *Message) bool { return true }, true)
fh.SetLogger(tl)
if fh.l != tl {
t.Errorf("expected the logger to be set")
}
}
func TestHandle(t *testing.T) {
fh := NewFileHandler("/tmp/test", 1, func(m *Message) bool { return true }, true)
handle := fh.Handle(&Message{time.Now(), 0, time.Now(), "localhost", "test", "message"})
if handle == nil {
t.Errorf("expected a handle, got nil")
}
}