github.com/blystad/deis@v0.11.0/logger/syslog/filehandler_test.go (about)

     1  package syslog
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  )
     7  
     8  type TestLogger struct{}
     9  
    10  func (tl TestLogger) Print(...interface{})                   {}
    11  func (tl TestLogger) Printf(format string, v ...interface{}) {}
    12  func (tl TestLogger) Println(...interface{})                 {}
    13  
    14  func TestNewFileHandler(t *testing.T) {
    15  	fh := NewFileHandler("", 1, func(m *Message) bool { return true }, true)
    16  	if fh == nil {
    17  		t.Errorf("expected filehandler, got nil")
    18  	}
    19  }
    20  
    21  func TestSetLogger(t *testing.T) {
    22  	tl := TestLogger{}
    23  	fh := NewFileHandler("", 1, func(m *Message) bool { return true }, true)
    24  	fh.SetLogger(tl)
    25  	if fh.l != tl {
    26  		t.Errorf("expected the logger to be set")
    27  	}
    28  }
    29  
    30  func TestHandle(t *testing.T) {
    31  	fh := NewFileHandler("/tmp/test", 1, func(m *Message) bool { return true }, true)
    32  	handle := fh.Handle(&Message{time.Now(), nil, 0, 0, time.Now(), "localhost", "test", "message", "", ""})
    33  	if handle == nil {
    34  		t.Errorf("expected a handle, got nil")
    35  	}
    36  }