Skip to content

Commit 10ce28b

Browse files
committed
Fix progress assertion message
1 parent 96bca5c commit 10ce28b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

core/src/commonIntegrationTest/kotlin/com/powersync/sync/SyncProgressTest.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import com.powersync.bucket.OplogEntry
1010
import com.powersync.testutils.ActiveDatabaseTest
1111
import com.powersync.testutils.databaseTest
1212
import com.powersync.testutils.waitFor
13+
import io.kotest.assertions.withClue
14+
import io.kotest.matchers.properties.shouldHaveValue
1315
import kotlinx.coroutines.channels.Channel
1416
import kotlin.test.BeforeTest
1517
import kotlin.test.Test
16-
import kotlin.test.assertEquals
1718
import kotlin.test.assertFalse
1819
import kotlin.test.assertNull
1920
import 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

Comments
 (0)