File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
commonMain/kotlin/com/powersync/sync
commonTest/kotlin/com/powersync/sync Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ import com.powersync.bucket.LocalOperationCounters
1414 * on [SyncStatusData].
1515 */
1616public data class ProgressWithOperations (
17+ val completed : Int ,
1718 val total : Int ,
18- val completed : Int
1919) {
2020 /* *
2121 * The relative amount of [total] items that have been [completed], as a number between `0.0` and `1.0`.
@@ -80,7 +80,7 @@ public data class SyncDownloadProgress private constructor(
8080 */
8181 public fun untilPriority (priority : BucketPriority ): ProgressWithOperations {
8282 val (total, completed) = targetAndCompletedCounts(priority)
83- return ProgressWithOperations (total, completed)
83+ return ProgressWithOperations (completed = completed, total = total )
8484 }
8585
8686 internal fun incrementDownloaded (batch : SyncDataBatch ): SyncDownloadProgress {
Original file line number Diff line number Diff line change 1+ package com.powersync.sync
2+
3+ import kotlin.test.Test
4+ import kotlin.test.assertEquals
5+
6+ class ProgressTest {
7+
8+ @Test
9+ fun reportsFraction () {
10+ assertEquals(0.0 , ProgressWithOperations (0 , 10 ).fraction)
11+ assertEquals(0.5 , ProgressWithOperations (5 , 10 ).fraction)
12+ assertEquals(1.0 , ProgressWithOperations (10 , 10 ).fraction)
13+
14+ assertEquals(0.0 , ProgressWithOperations (0 , 0 ).fraction)
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments