Skip to content

Commit 43836f6

Browse files
Update test scheduler
1 parent e94b966 commit 43836f6

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/media/MediaFilesRepository.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.woocommerce.android.util.CoroutineDispatchers
1010
import com.woocommerce.android.util.WooLog
1111
import com.woocommerce.android.util.WooLog.T
1212
import com.woocommerce.android.viewmodel.ResourceProvider
13+
import kotlinx.coroutines.DelicateCoroutinesApi
1314
import kotlinx.coroutines.ExperimentalCoroutinesApi
1415
import kotlinx.coroutines.channels.ProducerScope
1516
import kotlinx.coroutines.channels.awaitClose
@@ -59,7 +60,7 @@ class MediaFilesRepository @Inject constructor(
5960
}
6061
}
6162

62-
@OptIn(ExperimentalCoroutinesApi::class)
63+
@OptIn(DelicateCoroutinesApi::class)
6364
fun uploadMedia(localMediaModel: MediaModel, stripLocation: Boolean = true): Flow<UploadResult> {
6465
return callbackFlow {
6566
WooLog.d(T.MEDIA, "MediaFilesRepository > Dispatching request to upload ${localMediaModel.filePath}")

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/reviews/ReviewModerationHandlerTests.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class ReviewModerationHandlerTests {
8686

8787
val latestStatus = runTestAndCollectLastStatus {
8888
handler.postModerationRequest(review, HOLD)
89-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY)
89+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY); runCurrent() }
9090
}
9191

9292
assertThat(latestStatus.actionStatus).isEqualTo(ActionStatus.SUBMITTED)
@@ -108,7 +108,7 @@ class ReviewModerationHandlerTests {
108108

109109
val latestStatus = runTestAndCollectLastStatus {
110110
handler.postModerationRequest(review, HOLD)
111-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY)
111+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY); runCurrent() }
112112
}
113113

114114
assertThat(latestStatus.actionStatus).isEqualTo(ActionStatus.SUCCESS)
@@ -130,8 +130,8 @@ class ReviewModerationHandlerTests {
130130

131131
val statusList = runTestAndReturnLastEmittedStatusList {
132132
handler.postModerationRequest(review, HOLD)
133-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY)
134-
advanceTimeBy(ReviewModerationHandler.SUCCESS_DELAY)
133+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY); runCurrent() }
134+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.SUCCESS_DELAY); runCurrent() }
135135
}
136136

137137
assertThat(statusList).isEmpty()
@@ -149,7 +149,7 @@ class ReviewModerationHandlerTests {
149149

150150
val latestStatus = runTestAndCollectLastStatus {
151151
handler.postModerationRequest(review, HOLD)
152-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY)
152+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY); runCurrent() }
153153
}
154154

155155
assertThat(latestStatus.actionStatus).isEqualTo(ActionStatus.ERROR)
@@ -167,8 +167,8 @@ class ReviewModerationHandlerTests {
167167

168168
val statusList = runTestAndReturnLastEmittedStatusList {
169169
handler.postModerationRequest(review, HOLD)
170-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY)
171-
advanceTimeBy(ReviewModerationHandler.ERROR_SNACKBAR_DELAY)
170+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY); runCurrent() }
171+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.ERROR_SNACKBAR_DELAY); runCurrent() }
172172
}
173173

174174
assertThat(statusList).isEmpty()
@@ -180,7 +180,7 @@ class ReviewModerationHandlerTests {
180180

181181
val latestStatus = runTestAndCollectLastStatus {
182182
handler.postModerationRequest(review, HOLD)
183-
advanceTimeBy(ReviewModerationHandler.UNDO_DELAY / 2)
183+
testScheduler.apply { advanceTimeBy(ReviewModerationHandler.UNDO_DELAY / 2); runCurrent() }
184184
handler.undoOperation(review)
185185
}
186186

0 commit comments

Comments
 (0)