add compareAndDelete event action
parent
5b739f6166
commit
90a8f56c96
|
@ -11,6 +11,7 @@ const (
|
|||
Update = "update"
|
||||
Delete = "delete"
|
||||
CompareAndSwap = "compareAndSwap"
|
||||
CompareAndDelete = "compareAndDelete"
|
||||
Expire = "expire"
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue