FakeWatcher with channel size constructor

This commit is contained in:
Marcin Wielgus
2016-09-08 12:30:40 +02:00
parent aff7dfcaab
commit 13a80ce912
2 changed files with 34 additions and 32 deletions

View File

@@ -89,6 +89,12 @@ func NewFake() *FakeWatcher {
}
}
func NewFakeWithChanSize(size int) *FakeWatcher {
return &FakeWatcher{
result: make(chan Event, size),
}
}
// Stop implements Interface.Stop().
func (f *FakeWatcher) Stop() {
f.Lock()
@@ -99,6 +105,12 @@ func (f *FakeWatcher) Stop() {
}
}
func (f *FakeWatcher) IsStopped() bool {
f.Lock()
defer f.Unlock()
return f.Stopped
}
// Reset prepares the watcher to be reused.
func (f *FakeWatcher) Reset() {
f.Lock()