Pick entry with newer tombstone to merge
This commit is contained in:
1 parent
010766fe9e
commit
38a79b7f59
2 files changed
+18
No files matched your search
@@ -93,6 +93,9 @@ func (e1 *Entry) merge(e2 *Entry) bool {
|
||||
e1.Version = e2.Version
|
||||
e1.Tombstone = e2.Tombstone
|
||||
return true
|
||||
} else if e2.Version == e1.Version && e2.Tombstone > e1.Tombstone {
|
||||
e1.Tombstone = e2.Tombstone
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -86,6 +86,21 @@ func TestTombstone(t *testing.T) {
|
||||
Entry{Hostname: "B", Version: 1, Tombstone: 1234},
|
||||
})
|
||||
require.Equal(t, expected, es)
|
||||
|
||||
// Now try a merge including two entries which differ only in tombstone
|
||||
e2 := make(Entries, len(es))
|
||||
copy(e2, es)
|
||||
e2[1].Tombstone = 5555
|
||||
|
||||
diff := es.merge(e2)
|
||||
|
||||
expected2 := l(Entries{
|
||||
Entry{Hostname: "A"},
|
||||
Entry{Hostname: "B", Version: 1, Tombstone: 5555},
|
||||
})
|
||||
require.Equal(t, expected2, es)
|
||||
expectedDiff := l(Entries{Entry{Hostname: "B", Version: 1, Tombstone: 5555}})
|
||||
require.Equal(t, expectedDiff, diff)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user