@@ -10,10 +10,11 @@ import com.powersync.bucket.OplogEntry
10
10
import com.powersync.testutils.ActiveDatabaseTest
11
11
import com.powersync.testutils.databaseTest
12
12
import com.powersync.testutils.waitFor
13
+ import io.kotest.assertions.withClue
14
+ import io.kotest.matchers.properties.shouldHaveValue
13
15
import kotlinx.coroutines.channels.Channel
14
16
import kotlin.test.BeforeTest
15
17
import kotlin.test.Test
16
- import kotlin.test.assertEquals
17
18
import kotlin.test.assertFalse
18
19
import kotlin.test.assertNull
19
20
import kotlin.test.assertTrue
@@ -75,6 +76,16 @@ class SyncProgressTest {
75
76
}
76
77
}
77
78
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
+
78
89
private suspend fun ReceiveTurbine<SyncStatusData>.expectProgress (
79
90
total : Pair <Int , Int >,
80
91
priorities : Map <BucketPriority , Pair <Int , Int >> = emptyMap(),
@@ -83,19 +94,12 @@ class SyncProgressTest {
83
94
val progress = item.downloadProgress ? : error(" Expected download progress on $item " )
84
95
85
96
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)
91
98
92
99
priorities.forEach { (priority, expected) ->
93
100
val (expectedDownloaded, expectedTotal) = expected
94
101
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)
99
103
}
100
104
}
101
105
0 commit comments