Skip to content

Commit 924c45d

Browse files
committed
Ignore events after cancelling turbine
1 parent 482082c commit 924c45d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

core/src/commonIntegrationTest/kotlin/com/powersync/SyncIntegrationTest.kt

+13-13
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class SyncIntegrationTest {
139139

140140
database.close()
141141
turbine.waitFor { !it.connected }
142-
turbine.cancel()
142+
turbine.cancelAndIgnoreRemainingEvents()
143143
}
144144

145145
// Closing the database should have closed the channel
@@ -159,7 +159,7 @@ class SyncIntegrationTest {
159159

160160
database.disconnect()
161161
turbine.waitFor { !it.connected }
162-
turbine.cancel()
162+
turbine.cancelAndIgnoreRemainingEvents()
163163
}
164164

165165
// Disconnecting should have closed the channel
@@ -178,7 +178,7 @@ class SyncIntegrationTest {
178178
turbineScope(timeout = 10.0.seconds) {
179179
val turbine = database.currentStatus.asFlow().testIn(this)
180180
turbine.waitFor { it.connected }
181-
turbine.cancel()
181+
turbine.cancelAndIgnoreRemainingEvents()
182182
}
183183

184184
assertFailsWith<PowerSyncException>("Cannot update schema while connected") {
@@ -276,7 +276,7 @@ class SyncIntegrationTest {
276276
turbine.waitFor { it.hasSynced == true }
277277
expectUserCount(4)
278278

279-
turbine.cancel()
279+
turbine.cancelAndIgnoreRemainingEvents()
280280
}
281281

282282
syncLines.close()
@@ -349,7 +349,7 @@ class SyncIntegrationTest {
349349

350350
syncLines.send(SyncLine.CheckpointComplete(lastOpId = "1"))
351351
turbine.waitFor { !it.downloading }
352-
turbine.cancel()
352+
turbine.cancelAndIgnoreRemainingEvents()
353353
}
354354

355355
database.close()
@@ -369,7 +369,7 @@ class SyncIntegrationTest {
369369
database.disconnect()
370370

371371
turbine.waitFor { !it.connecting && !it.connected }
372-
turbine.cancel()
372+
turbine.cancelAndIgnoreRemainingEvents()
373373
}
374374

375375
database.close()
@@ -414,7 +414,7 @@ class SyncIntegrationTest {
414414
assertEquals(1, rows.size)
415415
}
416416

417-
turbine.cancel()
417+
turbine.cancelAndIgnoreRemainingEvents()
418418
}
419419

420420
database.close()
@@ -486,8 +486,8 @@ class SyncIntegrationTest {
486486
db2.disconnect()
487487
turbine2.waitFor { !it.connecting }
488488

489-
turbine1.cancel()
490-
turbine2.cancel()
489+
turbine1.cancelAndIgnoreRemainingEvents()
490+
turbine2.cancelAndIgnoreRemainingEvents()
491491
}
492492

493493
db2.close()
@@ -512,7 +512,7 @@ class SyncIntegrationTest {
512512
database.disconnect()
513513
turbine.waitFor { !it.connecting }
514514

515-
turbine.cancel()
515+
turbine.cancelAndIgnoreRemainingEvents()
516516
}
517517

518518
database.close()
@@ -531,7 +531,7 @@ class SyncIntegrationTest {
531531
database.connect(connector, 1000L, retryDelayMs = 5000)
532532
turbine.waitFor { it.connecting }
533533

534-
turbine.cancel()
534+
turbine.cancelAndIgnoreRemainingEvents()
535535
}
536536

537537
database.close()
@@ -580,7 +580,7 @@ class SyncIntegrationTest {
580580
turbineScope {
581581
val turbine = database.currentStatus.asFlow().testIn(this)
582582
turbine.waitFor { it.downloading }
583-
turbine.cancel()
583+
turbine.cancelAndIgnoreRemainingEvents()
584584
}
585585

586586
syncLines.send(
@@ -635,7 +635,7 @@ class SyncIntegrationTest {
635635
turbineScope {
636636
val turbine = database.currentStatus.asFlow().testIn(this)
637637
turbine.waitFor { !it.downloading }
638-
turbine.cancel()
638+
turbine.cancelAndIgnoreRemainingEvents()
639639
}
640640

641641
// Meaning that the two rows are now visible

0 commit comments

Comments
 (0)