Browse Source

add compareAndDelete event action

rick 12 years ago
parent
commit
90a8f56c96
3 changed files with 4 additions and 3 deletions
  1. 1 0
      store/event.go
  2. 1 1
      store/store.go
  3. 2 2
      store/store_test.go

+ 1 - 0
store/event.go

@@ -11,6 +11,7 @@ const (
 	Update         = "update"
 	Delete         = "delete"
 	CompareAndSwap = "compareAndSwap"
+	CompareAndDelete = "compareAndDelete"
 	Expire         = "expire"
 )
 

+ 1 - 1
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

+ 2 - 2
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) {