From 0cc9b76d26a89dfadaf61e02ea00d69bd143aaea Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Fri, 19 Feb 2016 15:15:59 -0800 Subject: [PATCH] Fixed tests --- client/driver/logging/rotator.go | 6 +++--- client/driver/logging/syslog_parser_test.go | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/driver/logging/rotator.go b/client/driver/logging/rotator.go index d44e9d355..d106900d2 100644 --- a/client/driver/logging/rotator.go +++ b/client/driver/logging/rotator.go @@ -40,7 +40,7 @@ type FileRotator struct { currentWr int64 logger *log.Logger - purgeCh chan interface{} + purgeCh chan struct{} } // NewFileRotator returns a new file rotator @@ -54,7 +54,7 @@ func NewFileRotator(path string, baseFile string, maxFiles int, baseFileName: baseFile, logger: logger, - purgeCh: make(chan interface{}), + purgeCh: make(chan struct{}, 1), } if err := rotator.lastFile(); err != nil { return nil, err @@ -128,7 +128,7 @@ func (f *FileRotator) nextFile() error { // Purge old files if we have more files than MaxFiles if f.logFileIdx-f.oldestLogFileIdx >= f.MaxFiles { select { - case f.purgeCh <- new(interface{}): + case f.purgeCh <- struct{}{}: default: } } diff --git a/client/driver/logging/syslog_parser_test.go b/client/driver/logging/syslog_parser_test.go index 55503eee9..4f1416a1a 100644 --- a/client/driver/logging/syslog_parser_test.go +++ b/client/driver/logging/syslog_parser_test.go @@ -3,13 +3,15 @@ package logging import ( + "log" "log/syslog" + "os" "testing" ) func TestLogParser_Priority(t *testing.T) { line := []byte("<30>2016-02-10T10:16:43-08:00 d-thinkpad docker/e2a1e3ebd3a3[22950]: 1:C 10 Feb 18:16:43.391 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf") - d := NewDockerLogParser(line) + d := NewDockerLogParser(log.New(os.Stdout, "", log.LstdFlags)) p, _, err := d.parsePriority(line) if err != nil { t.Fatalf("got an err: %v", err)