github.com/leverly/deis@v1.0.2/logger/syslog/filehandler_test.go (about)

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