@@ -272,45 +272,47 @@ class SyncIntegrationTest {
272272 }
273273
274274 @Test
275- fun testMultipleSyncsDoNotCreateMultipleStatusEntries () = runTest {
276- val syncStream = syncStream()
277- database.connect(syncStream, 1000L )
275+ fun testMultipleSyncsDoNotCreateMultipleStatusEntries () =
276+ runTest {
277+ val syncStream = syncStream()
278+ database.connect(syncStream, 1000L )
278279
279- turbineScope(timeout = 10.0 .seconds) {
280- val turbine = database.currentStatus.asFlow().testIn(this )
281- turbine.waitFor { it.connected && ! it.downloading }
280+ turbineScope(timeout = 10.0 .seconds) {
281+ val turbine = database.currentStatus.asFlow().testIn(this )
282+ turbine.waitFor { it.connected && ! it.downloading }
282283
283- repeat(5 ) {
284- syncLines.send(
285- SyncLine .FullCheckpoint (
286- Checkpoint (
287- lastOpId = " 1" ,
288- checksums =
289- listOf (
290- BucketChecksum (
291- bucket = " bkt" ,
292- checksum = 0 ,
293- ),
284+ repeat(5 ) {
285+ syncLines.send(
286+ SyncLine .FullCheckpoint (
287+ Checkpoint (
288+ lastOpId = " 1" ,
289+ checksums =
290+ listOf (
291+ BucketChecksum (
292+ bucket = " bkt" ,
293+ checksum = 0 ,
294+ ),
295+ ),
294296 ),
295297 ),
296- ),
297- )
298- turbine.waitFor { it.downloading }
298+ )
299+ turbine.waitFor { it.downloading }
299300
300- syncLines.send(SyncLine .CheckpointComplete (lastOpId = " 1" ))
301- turbine.waitFor { ! it.downloading }
301+ syncLines.send(SyncLine .CheckpointComplete (lastOpId = " 1" ))
302+ turbine.waitFor { ! it.downloading }
303+
304+ val rows =
305+ database.getAll(" SELECT * FROM ps_sync_state;" ) {
306+ it.getString(1 )!!
307+ }
302308
303- val rows = database.getAll(" SELECT * FROM ps_sync_state;" ) {
304- it.getString(1 )!!
309+ assertEquals(1 , rows.size)
305310 }
306311
307- assertEquals( 1 , rows.size )
312+ turbine.cancel( )
308313 }
309314
310- turbine.cancel()
315+ database.close()
316+ syncLines.close()
311317 }
312-
313- database.close()
314- syncLines.close()
315- }
316318}
0 commit comments