Skip to content

Commit c0b8d92

Browse files
committed
Assert no duplicate status entries
1 parent b866741 commit c0b8d92

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/powersync_core/test/in_memory_sync_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,37 @@ void main() {
280280
.hasSynced,
281281
isFalse);
282282
});
283+
284+
test(
285+
"multiple completed syncs don't create multiple sync state entries",
286+
() async {
287+
final status = await waitForConnection();
288+
289+
for (var i = 0; i < 5; i++) {
290+
syncService.addLine({
291+
'checkpoint': Checkpoint(
292+
lastOpId: '0',
293+
writeCheckpoint: null,
294+
checksums: [
295+
BucketChecksum(bucket: 'bkt', priority: 1, checksum: 0)
296+
],
297+
)
298+
});
299+
await expectLater(status, emits(isSyncStatus(downloading: true)));
300+
301+
syncService.addLine({
302+
'checkpoint_complete': {
303+
'last_op_id': '0',
304+
}
305+
});
306+
307+
await expectLater(status, emits(isSyncStatus(downloading: false)));
308+
}
309+
310+
final rows = await database.getAll('SELECT * FROM ps_sync_state;');
311+
expect(rows, hasLength(1));
312+
},
313+
);
283314
});
284315
});
285316
}

0 commit comments

Comments
 (0)