Index: state/testing/watcher.go |
=== modified file 'state/testing/watcher.go' |
--- state/testing/watcher.go 2013-07-22 10:29:03 +0000 |
+++ state/testing/watcher.go 2013-08-02 18:20:04 +0000 |
@@ -51,9 +51,8 @@ |
// the behaviour of any watcher that uses a <-chan struct{}. |
type NotifyWatcherC struct { |
*C |
- State *state.State |
- Watcher NotifyWatcher |
- FullSync bool |
+ State *state.State |
+ Watcher NotifyWatcher |
} |
// NewNotifyWatcherC returns a NotifyWatcherC that checks for aggressive |
@@ -66,20 +65,8 @@ |
} |
} |
-// NewLaxNotifyWatcherC returns a NotifyWatcherC that runs a full watcher |
-// sync before reading from the watcher's Changes channel, and hence cannot |
-// verify real-world coalescence behaviour. |
-func NewLaxNotifyWatcherC(c *C, st *state.State, w NotifyWatcher) NotifyWatcherC { |
- return NotifyWatcherC{ |
- C: c, |
- State: st, |
- Watcher: w, |
- FullSync: true, |
- } |
-} |
- |
func (c NotifyWatcherC) AssertNoChange() { |
- c.State.StartSync() |
+ c.State.Sync() |
select { |
case _, ok := <-c.Watcher.Changes(): |
c.Fatalf("watcher sent unexpected change: (_, %v)", ok) |
@@ -88,11 +75,7 @@ |
} |
func (c NotifyWatcherC) AssertOneChange() { |
- if c.FullSync { |
- c.State.Sync() |
- } else { |
- c.State.StartSync() |
- } |
+ c.State.Sync() |
select { |
case _, ok := <-c.Watcher.Changes(): |
c.Assert(ok, Equals, true) |
@@ -115,9 +98,8 @@ |
// the behaviour of any watcher that uses a <-chan []string. |
type StringsWatcherC struct { |
*C |
- State *state.State |
- Watcher StringsWatcher |
- FullSync bool |
+ State *state.State |
+ Watcher StringsWatcher |
} |
// NewStringsWatcherC returns a StringsWatcherC that checks for aggressive |
@@ -130,25 +112,13 @@ |
} |
} |
-// NewLaxStringsWatcherC returns a StringsWatcherC that runs a full watcher |
-// sync before reading from the watcher's Changes channel, and hence cannot |
-// verify real-world coalescence behaviour. |
-func NewLaxStringsWatcherC(c *C, st *state.State, w StringsWatcher) StringsWatcherC { |
- return StringsWatcherC{ |
- C: c, |
- State: st, |
- Watcher: w, |
- FullSync: true, |
- } |
-} |
- |
type StringsWatcher interface { |
Stop() error |
Changes() <-chan []string |
} |
func (c StringsWatcherC) AssertNoChange() { |
- c.State.StartSync() |
+ c.State.Sync() |
select { |
case actual, ok := <-c.Watcher.Changes(): |
c.Fatalf("watcher sent unexpected change: (%v, %v)", actual, ok) |
@@ -159,11 +129,7 @@ |
// AssertChange asserts the given list of changes was reported by |
// the watcher, but does not assume there are no following changes. |
func (c StringsWatcherC) AssertChange(expect ...string) { |
- if c.FullSync { |
- c.State.Sync() |
- } else { |
- c.State.StartSync() |
- } |
+ c.State.Sync() |
timeout := time.After(testing.LongWait) |
var actual []string |
loop: |