@@ -10,10 +10,11 @@ import com.powersync.bucket.OplogEntry
1010import com.powersync.testutils.ActiveDatabaseTest
1111import com.powersync.testutils.databaseTest
1212import com.powersync.testutils.waitFor
13+ import io.kotest.assertions.withClue
14+ import io.kotest.matchers.properties.shouldHaveValue
1315import kotlinx.coroutines.channels.Channel
1416import kotlin.test.BeforeTest
1517import kotlin.test.Test
16- import kotlin.test.assertEquals
1718import kotlin.test.assertFalse
1819import kotlin.test.assertNull
1920import kotlin.test.assertTrue
@@ -75,6 +76,16 @@ class SyncProgressTest {
7576 }
7677 }
7778
79+ private fun ProgressWithOperations.shouldBe (
80+ downloaded : Int ,
81+ total : Int ,
82+ ) {
83+ withClue(" progress $downloadedOperations /$totalOperations should be $downloaded /$total " ) {
84+ this ::downloadedOperations shouldHaveValue downloaded
85+ this ::totalOperations shouldHaveValue total
86+ }
87+ }
88+
7889 private suspend fun ReceiveTurbine<SyncStatusData>.expectProgress (
7990 total : Pair <Int , Int >,
8091 priorities : Map <BucketPriority , Pair <Int , Int >> = emptyMap(),
@@ -83,19 +94,12 @@ class SyncProgressTest {
8394 val progress = item.downloadProgress ? : error(" Expected download progress on $item " )
8495
8596 assertTrue { item.downloading }
86- run {
87- val message = " Expected total progress to be ${total.first} /${total.second} , but it is ${progress.downloadedOperations} /${progress.totalOperations} "
88- assertEquals(total.first, progress.downloadedOperations, message)
89- assertEquals(total.second, progress.totalOperations, message)
90- }
97+ progress.shouldBe(total.first, total.second)
9198
9299 priorities.forEach { (priority, expected) ->
93100 val (expectedDownloaded, expectedTotal) = expected
94101 val actualProgress = progress.untilPriority(priority)
95- val message = " Expected progress at prio $priority to be ${expectedDownloaded} /${expectedTotal} , but it is ${actualProgress.downloadedOperations} /${actualProgress.totalOperations} "
96-
97- assertEquals(expectedDownloaded, actualProgress.downloadedOperations, message)
98- assertEquals(expectedTotal, actualProgress.totalOperations, message)
102+ actualProgress.shouldBe(expectedDownloaded, expectedTotal)
99103 }
100104 }
101105
0 commit comments