Skip to content

Commit b612549

Browse files
committed
Additional tests for REMOVE operations.
1 parent 5b94ff0 commit b612549

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

packages/powersync/test/bucket_storage_test.dart

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,50 @@ void main() {
170170
await expectNoAssets();
171171
});
172172

173+
test('put then remove', () async {
174+
await bucketStorage.saveSyncData(SyncDataBatch([
175+
SyncBucketData(bucket: 'bucket1', data: [putAsset1_3]),
176+
]));
177+
178+
await syncLocalChecked(Checkpoint(lastOpId: '3', checksums: [
179+
BucketChecksum(bucket: 'bucket1', checksum: 3),
180+
]));
181+
182+
await expectAsset1_3();
183+
184+
await bucketStorage.saveSyncData(SyncDataBatch([
185+
SyncBucketData(bucket: 'bucket1', data: [removeAsset1_5])
186+
]));
187+
188+
await syncLocalChecked(Checkpoint(lastOpId: '5', checksums: [
189+
BucketChecksum(bucket: 'bucket1', checksum: 8),
190+
]));
191+
192+
await expectNoAssets();
193+
});
194+
195+
test('blank remove', () async {
196+
await bucketStorage.saveSyncData(SyncDataBatch([
197+
SyncBucketData(bucket: 'bucket1', data: [putAsset1_3, removeAsset1_4]),
198+
]));
199+
200+
await syncLocalChecked(Checkpoint(lastOpId: '4', checksums: [
201+
BucketChecksum(bucket: 'bucket1', checksum: 7),
202+
]));
203+
204+
await expectNoAssets();
205+
206+
await bucketStorage.saveSyncData(SyncDataBatch([
207+
SyncBucketData(bucket: 'bucket1', data: [removeAsset1_5])
208+
]));
209+
210+
await syncLocalChecked(Checkpoint(lastOpId: '5', checksums: [
211+
BucketChecksum(bucket: 'bucket1', checksum: 12),
212+
]));
213+
214+
await expectNoAssets();
215+
});
216+
173217
test('should use subkeys', () async {
174218
// subkeys cause this to be treated as a separate entity in the oplog,
175219
// but same entity in the local db.

0 commit comments

Comments
 (0)