File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
OneSignalSDK/onesignal/core/src/test/java/com/onesignal/core/internal/operations Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,12 @@ class OperationRepoTests : FunSpec({
157
157
// When
158
158
operationRepo.start()
159
159
operationRepo.enqueue(MyOperation ())
160
+ // Wait for the background coroutine to complete enqueue
161
+ withTimeout(1000) {
162
+ while (operationRepo.queue.size == 0) {
163
+ delay(10)
164
+ }
165
+ }
160
166
161
167
// Then
162
168
operationRepo.containsInstanceOf<MyOperation >() shouldBe true
@@ -609,6 +615,12 @@ class OperationRepoTests : FunSpec({
609
615
// When
610
616
mocks.operationRepo.start()
611
617
mocks.operationRepo.enqueue(operation1)
618
+ // Wait for the background coroutine to complete enqueue
619
+ withTimeout(1000) {
620
+ while (mocks.operationRepo.queue.size == 0) {
621
+ delay(10)
622
+ }
623
+ }
612
624
val job = launch { mocks.operationRepo.enqueueAndWait(operation2) }.also { yield () }
613
625
mocks.operationRepo.enqueueAndWait(operation3)
614
626
job.join()
@@ -639,6 +651,12 @@ class OperationRepoTests : FunSpec({
639
651
mocks.operationRepo.start()
640
652
mocks.operationRepo.enqueue(operation1)
641
653
mocks.operationRepo.enqueue(operation2)
654
+ // Wait for the background coroutine to complete enqueue
655
+ withTimeout(1000) {
656
+ while (mocks.operationRepo.queue.size < 2) {
657
+ delay(10)
658
+ }
659
+ }
642
660
mocks.operationRepo.enqueueAndWait(operation3)
643
661
644
662
// Then
You can’t perform that action at this time.
0 commit comments