Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ object OSPrimaryCoroutineScope {
block()
}
}

suspend fun waitForIdle() = mainScope.launch { }.join()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.onesignal.core.internal.operations

import com.onesignal.common.threading.OSPrimaryCoroutineScope
import com.onesignal.common.threading.Waiter
import com.onesignal.common.threading.WaiterWithValue
import com.onesignal.core.internal.operations.impl.OperationModelStore
Expand Down Expand Up @@ -100,6 +101,7 @@ class OperationRepoTests : FunSpec({
listOf(mocks.executor),
operationModelStore,
mocks.configModelStore,
mocks.identityModelStore,
Time(),
getNewRecordState(mocks.configModelStore),
),
Expand Down Expand Up @@ -165,6 +167,7 @@ class OperationRepoTests : FunSpec({
// When
operationRepo.start()
operationRepo.enqueue(MyOperation())
OSPrimaryCoroutineScope.waitForIdle()

// Then
operationRepo.containsInstanceOf<MyOperation>() shouldBe true
Expand Down Expand Up @@ -269,6 +272,7 @@ class OperationRepoTests : FunSpec({
// When
opRepo.start()
opRepo.enqueue(mockOperation())
OSPrimaryCoroutineScope.waitForIdle()
val response1 =
withTimeoutOrNull(999) {
opRepo.enqueueAndWait(mockOperation())
Expand Down Expand Up @@ -647,6 +651,7 @@ class OperationRepoTests : FunSpec({
mocks.operationRepo.start()
mocks.operationRepo.enqueue(operation1)
mocks.operationRepo.enqueue(operation2)
OSPrimaryCoroutineScope.waitForIdle()
mocks.operationRepo.enqueueAndWait(operation3)

// Then
Expand Down Expand Up @@ -727,6 +732,7 @@ class OperationRepoTests : FunSpec({
val mocks = Mocks()
val op = mockOperation()
mocks.operationRepo.enqueue(op)
OSPrimaryCoroutineScope.waitForIdle()

// When
mocks.operationRepo.loadSavedOperations()
Expand Down Expand Up @@ -767,6 +773,7 @@ class OperationRepoTests : FunSpec({
// When
opRepo.start()
opRepo.enqueue(mockOperation())
OSPrimaryCoroutineScope.waitForIdle()
val response1 =
withTimeoutOrNull(999) {
opRepo.enqueueAndWait(mockOperation())
Expand Down
Loading