From 90a8f56c963398bcb05141a40b444370adcc7796 Mon Sep 17 00:00:00 2001 From: rick Date: Sat, 30 Nov 2013 10:08:25 -0700 Subject: [PATCH] add compareAndDelete event action --- store/event.go | 1 + store/store.go | 2 +- store/store_test.go | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/store/event.go b/store/event.go index f3d607e0b..f7a846717 100644 --- a/store/event.go +++ b/store/event.go @@ -11,6 +11,7 @@ const ( Update = "update" Delete = "delete" CompareAndSwap = "compareAndSwap" + CompareAndDelete = "compareAndDelete" Expire = "expire" ) diff --git a/store/store.go b/store/store.go index 08a9e1702..eb88f5c82 100644 --- a/store/store.go +++ b/store/store.go @@ -304,7 +304,7 @@ func (s *store) CompareAndDelete(nodePath string, prevValue string, prevIndex ui // Command will be executed, only if both of the tests are successful. if (prevValue == "" || n.Value == prevValue) && (prevIndex == 0 || n.ModifiedIndex == prevIndex) { - e := newEvent(Delete, nodePath, s.CurrentIndex+1) + e := newEvent(CompareAndDelete, nodePath, s.CurrentIndex+1) e.PrevValue = n.Value callback := func(path string) { // notify function diff --git a/store/store_test.go b/store/store_test.go index 8699e1e69..e70cc5419 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -209,7 +209,7 @@ func TestStoreCompareAndDeletePrevValue(t *testing.T) { s.Create("/foo", "bar", false, Permanent) e, err := s.CompareAndDelete("/foo", "bar", 0) assert.Nil(t, err, "") - assert.Equal(t, e.Action, "delete", "") + assert.Equal(t, e.Action, "compareAndDelete", "") } func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) { @@ -229,7 +229,7 @@ func TestStoreCompareAndDeletePrevIndex(t *testing.T) { s.Create("/foo", "bar", false, Permanent) e, err := s.CompareAndDelete("/foo", "", 1) assert.Nil(t, err, "") - assert.Equal(t, e.Action, "delete", "") + assert.Equal(t, e.Action, "compareAndDelete", "") } func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) {