From f568a1ccfc72e94c5aadc260620ca877bbac6624 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Thu, 31 Dec 2015 19:26:42 -0800 Subject: [PATCH] storage: watcher_test.go events slice --- storage/watcher_test.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/storage/watcher_test.go b/storage/watcher_test.go index c3adabf69..412ee718e 100644 --- a/storage/watcher_test.go +++ b/storage/watcher_test.go @@ -27,7 +27,6 @@ func TestWatcherWatchID(t *testing.T) { idm := make(map[int64]struct{}) - // synced watchings for i := 0; i < 10; i++ { id, cancel := w.Watch([]byte("foo"), false, 0) if _, ok := idm[id]; ok { @@ -37,15 +36,17 @@ func TestWatcherWatchID(t *testing.T) { s.Put([]byte("foo"), []byte("bar")) - ev := <-w.Chan() - if ev.WatchID != id { - t.Errorf("#%d: watch id in event = %d, want %d", i, ev.WatchID, id) + evs := <-w.Chan() + for j, ev := range evs { + if ev.WatchID != id { + t.Errorf("#%d.%d: watch id in event = %d, want %d", i, j, ev.WatchID, id) + } } - cancel() } s.Put([]byte("foo2"), []byte("bar")) + // unsynced watchings for i := 10; i < 20; i++ { id, cancel := w.Watch([]byte("foo2"), false, 1) @@ -54,9 +55,11 @@ func TestWatcherWatchID(t *testing.T) { } idm[id] = struct{}{} - ev := <-w.Chan() - if ev.WatchID != id { - t.Errorf("#%d: watch id in event = %d, want %d", i, ev.WatchID, id) + evs := <-w.Chan() + for j, ev := range evs { + if ev.WatchID != id { + t.Errorf("#%d.%d: watch id in event = %d, want %d", i, j, ev.WatchID, id) + } } cancel()