@@ -92,6 +92,38 @@ func TestGetMergeOperator(t *testing.T) {
92
92
})
93
93
})
94
94
95
+ t .Run ("Get after Delete" , func (t * testing.T ) {
96
+ key := []byte ("merge" )
97
+ runBadgerTest (t , nil , func (t * testing.T , db * DB ) {
98
+ m := db .GetMergeOperator (key , add , 200 * time .Millisecond )
99
+
100
+ err := m .Add (uint64ToBytes (1 ))
101
+ require .NoError (t , err )
102
+ m .Add (uint64ToBytes (2 ))
103
+ require .NoError (t , err )
104
+ m .Add (uint64ToBytes (3 ))
105
+ require .NoError (t , err )
106
+
107
+ m .Stop ()
108
+ res , err := m .Get ()
109
+ require .NoError (t , err )
110
+ require .Equal (t , uint64 (6 ), bytesToUint64 (res ))
111
+
112
+ db .Update (func (txn * Txn ) error {
113
+ return txn .Delete (key )
114
+ })
115
+
116
+ m = db .GetMergeOperator (key , add , 200 * time .Millisecond )
117
+ err = m .Add (uint64ToBytes (1 ))
118
+ require .NoError (t , err )
119
+ m .Stop ()
120
+
121
+ res , err = m .Get ()
122
+ require .NoError (t , err )
123
+ require .Equal (t , uint64 (1 ), bytesToUint64 (res ))
124
+ })
125
+ })
126
+
95
127
t .Run ("Get after Stop" , func (t * testing.T ) {
96
128
key := []byte ("merge" )
97
129
runBadgerTest (t , nil , func (t * testing.T , db * DB ) {
0 commit comments