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 @@ -239,7 +239,7 @@ class HttpClientTests : FunSpec({

mocks.factory.mockResponse = mockSuccessfulResponse
val response2 =
withTimeoutOrNull(999) {
withTimeoutOrNull(975) {
Comment thread
jinliu9508 marked this conversation as resolved.
mocks.httpClient.post("URL", JSONObject())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ class OperationRepoTests : FunSpec({
// When
mocks.operationRepo.addOperationLoadedListener(spyListener)
mocks.operationRepo.start()
// enqueueAndWait used to know we are fully loaded.
mocks.operationRepo.enqueueAndWait(mockOperation())

// Then
mocks.operationRepo.hasSubscribers shouldBe true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.onesignal.user.internal.migrations

import com.onesignal.common.threading.Waiter
import com.onesignal.core.internal.config.ConfigModelStore
import com.onesignal.core.internal.operations.IOperationRepoLoadedListener
import com.onesignal.core.internal.operations.impl.OperationModelStore
import com.onesignal.core.internal.operations.impl.OperationRepo
import com.onesignal.core.internal.time.impl.Time
Expand Down Expand Up @@ -31,16 +33,24 @@ class RecoverFromDroppedLoginBugTests : FunSpec({
)
every { mockOperationModelStore.loadOperations() } just runs
every { mockOperationModelStore.list() } returns listOf()

val recovery = RecoverFromDroppedLoginBug(operationRepo, MockHelper.identityModelStore(), mockConfigModelStore)
every { recovery.onOperationRepoLoaded() } just runs
val recovery = spyk(RecoverFromDroppedLoginBug(operationRepo, MockHelper.identityModelStore(), mockConfigModelStore))

// When
operationRepo.start()
recovery.start()
val waiter = Waiter()
operationRepo.addOperationLoadedListener(
object : IOperationRepoLoadedListener {
override fun onOperationRepoLoaded() {
waiter.wake()
}
},
)
operationRepo.start()
Comment thread
jinliu9508 marked this conversation as resolved.
// Waiting here ensures recovery.onOperationRepoLoaded() is called consistently
waiter.waitForWake()

// Then
verify {
verify(exactly = 1) {
operationRepo.subscribe(recovery)
recovery.onOperationRepoLoaded()
}
Expand Down