File tree 2 files changed +18
-2
lines changed
commonMain/kotlin/com/powersync/sync
commonTest/kotlin/com/powersync/sync
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
14
14
* on [SyncStatusData].
15
15
*/
16
16
public data class ProgressWithOperations (
17
+ val completed : Int ,
17
18
val total : Int ,
18
- val completed : Int
19
19
) {
20
20
/* *
21
21
* 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(
80
80
*/
81
81
public fun untilPriority (priority : BucketPriority ): ProgressWithOperations {
82
82
val (total, completed) = targetAndCompletedCounts(priority)
83
- return ProgressWithOperations (total, completed)
83
+ return ProgressWithOperations (completed = completed, total = total )
84
84
}
85
85
86
86
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