2019-01-28 22:52:47 +00:00
|
|
|
package fakes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hpcloud/tail"
|
|
|
|
"gopkg.in/tomb.v1"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockTailer struct {
|
2019-04-24 20:05:57 +00:00
|
|
|
Lines chan *tail.Line
|
|
|
|
TailErr error
|
2019-01-28 22:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewMockTailer() *MockTailer {
|
|
|
|
return &MockTailer{
|
2019-04-24 20:05:57 +00:00
|
|
|
Lines: make(chan *tail.Line, 1),
|
2019-01-28 22:52:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mock *MockTailer) Tail() (*tail.Tail, error) {
|
|
|
|
fakeTail := &tail.Tail{
|
|
|
|
Filename: "",
|
|
|
|
Lines: mock.Lines,
|
|
|
|
Config: tail.Config{},
|
|
|
|
Tomb: tomb.Tomb{},
|
|
|
|
}
|
2019-04-24 20:05:57 +00:00
|
|
|
return fakeTail, mock.TailErr
|
2019-01-28 22:52:47 +00:00
|
|
|
}
|