|
@@ -446,7 +446,7 @@ func TestStoreCompareAndSwapPrevIndexFailsIfNotMatch(t *testing.T) {
|
|
|
// Ensure that the store can watch for key creation.
|
|
// Ensure that the store can watch for key creation.
|
|
|
func TestStoreWatchCreate(t *testing.T) {
|
|
func TestStoreWatchCreate(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
- w, _ := s.NewWatcher("/foo", false, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", false, 0)
|
|
|
c := w.EventChan
|
|
c := w.EventChan
|
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
|
e := nbselect(c)
|
|
e := nbselect(c)
|
|
@@ -459,7 +459,7 @@ func TestStoreWatchCreate(t *testing.T) {
|
|
|
// Ensure that the store can watch for recursive key creation.
|
|
// Ensure that the store can watch for recursive key creation.
|
|
|
func TestStoreWatchRecursiveCreate(t *testing.T) {
|
|
func TestStoreWatchRecursiveCreate(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
- w, _ := s.NewWatcher("/foo", true, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", true, 0)
|
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "create", "")
|
|
assert.Equal(t, e.Action, "create", "")
|
|
@@ -470,7 +470,7 @@ func TestStoreWatchRecursiveCreate(t *testing.T) {
|
|
|
func TestStoreWatchUpdate(t *testing.T) {
|
|
func TestStoreWatchUpdate(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", false, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", false, 0)
|
|
|
s.Update("/foo", "baz", Permanent)
|
|
s.Update("/foo", "baz", Permanent)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "update", "")
|
|
assert.Equal(t, e.Action, "update", "")
|
|
@@ -481,7 +481,7 @@ func TestStoreWatchUpdate(t *testing.T) {
|
|
|
func TestStoreWatchRecursiveUpdate(t *testing.T) {
|
|
func TestStoreWatchRecursiveUpdate(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", true, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", true, 0)
|
|
|
s.Update("/foo/bar", "baz", Permanent)
|
|
s.Update("/foo/bar", "baz", Permanent)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "update", "")
|
|
assert.Equal(t, e.Action, "update", "")
|
|
@@ -492,7 +492,7 @@ func TestStoreWatchRecursiveUpdate(t *testing.T) {
|
|
|
func TestStoreWatchDelete(t *testing.T) {
|
|
func TestStoreWatchDelete(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", false, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", false, 0)
|
|
|
s.Delete("/foo", false, false)
|
|
s.Delete("/foo", false, false)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "delete", "")
|
|
assert.Equal(t, e.Action, "delete", "")
|
|
@@ -503,7 +503,7 @@ func TestStoreWatchDelete(t *testing.T) {
|
|
|
func TestStoreWatchRecursiveDelete(t *testing.T) {
|
|
func TestStoreWatchRecursiveDelete(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", true, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", true, 0)
|
|
|
s.Delete("/foo/bar", false, false)
|
|
s.Delete("/foo/bar", false, false)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "delete", "")
|
|
assert.Equal(t, e.Action, "delete", "")
|
|
@@ -514,7 +514,7 @@ func TestStoreWatchRecursiveDelete(t *testing.T) {
|
|
|
func TestStoreWatchCompareAndSwap(t *testing.T) {
|
|
func TestStoreWatchCompareAndSwap(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
s.Create("/foo", false, "bar", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", false, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", false, 0)
|
|
|
s.CompareAndSwap("/foo", "bar", 0, "baz", Permanent)
|
|
s.CompareAndSwap("/foo", "bar", 0, "baz", Permanent)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "compareAndSwap", "")
|
|
assert.Equal(t, e.Action, "compareAndSwap", "")
|
|
@@ -525,7 +525,7 @@ func TestStoreWatchCompareAndSwap(t *testing.T) {
|
|
|
func TestStoreWatchRecursiveCompareAndSwap(t *testing.T) {
|
|
func TestStoreWatchRecursiveCompareAndSwap(t *testing.T) {
|
|
|
s := newStore()
|
|
s := newStore()
|
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
s.Create("/foo/bar", false, "baz", false, Permanent)
|
|
|
- w, _ := s.NewWatcher("/foo", true, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/foo", true, 0)
|
|
|
s.CompareAndSwap("/foo/bar", "baz", 0, "bat", Permanent)
|
|
s.CompareAndSwap("/foo/bar", "baz", 0, "bat", Permanent)
|
|
|
e := nbselect(w.EventChan)
|
|
e := nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "compareAndSwap", "")
|
|
assert.Equal(t, e.Action, "compareAndSwap", "")
|
|
@@ -545,7 +545,7 @@ func TestStoreWatchExpire(t *testing.T) {
|
|
|
s.Create("/foo", false, "bar", false, time.Now().Add(500*time.Millisecond))
|
|
s.Create("/foo", false, "bar", false, time.Now().Add(500*time.Millisecond))
|
|
|
s.Create("/foofoo", false, "barbarbar", false, time.Now().Add(500*time.Millisecond))
|
|
s.Create("/foofoo", false, "barbarbar", false, time.Now().Add(500*time.Millisecond))
|
|
|
|
|
|
|
|
- w, _ := s.NewWatcher("/", true, 0)
|
|
|
|
|
|
|
+ w, _ := s.Watch("/", true, 0)
|
|
|
c := w.EventChan
|
|
c := w.EventChan
|
|
|
e := nbselect(c)
|
|
e := nbselect(c)
|
|
|
assert.Nil(t, e, "")
|
|
assert.Nil(t, e, "")
|
|
@@ -553,7 +553,7 @@ func TestStoreWatchExpire(t *testing.T) {
|
|
|
e = nbselect(c)
|
|
e = nbselect(c)
|
|
|
assert.Equal(t, e.Action, "expire", "")
|
|
assert.Equal(t, e.Action, "expire", "")
|
|
|
assert.Equal(t, e.Node.Key, "/foo", "")
|
|
assert.Equal(t, e.Node.Key, "/foo", "")
|
|
|
- w, _ = s.NewWatcher("/", true, 4)
|
|
|
|
|
|
|
+ w, _ = s.Watch("/", true, 4)
|
|
|
e = nbselect(w.EventChan)
|
|
e = nbselect(w.EventChan)
|
|
|
assert.Equal(t, e.Action, "expire", "")
|
|
assert.Equal(t, e.Action, "expire", "")
|
|
|
assert.Equal(t, e.Node.Key, "/foofoo", "")
|
|
assert.Equal(t, e.Node.Key, "/foofoo", "")
|