Skip to content

Commit

Permalink
chore: test mockative older version
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Nov 28, 2024
1 parent 19aa8bf commit 0f5b884
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class LogoutUseCaseTest {
.coroutine { clearRetainedClientId() }
.wasInvoked(exactly = once)
verify(arrangement.pushTokenRepository)
.coroutine { setUpdateFirebaseTokenFlag(eq(true)) }
.coroutine { setUpdateFirebaseTokenFlag(true) }
.wasInvoked(exactly = once)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import com.wire.kalium.util.FileUtil
import com.wire.kalium.util.KaliumDispatcherImpl
import io.mockative.Mock
import io.mockative.any
import io.mockative.coVerify
import io.mockative.every
import io.mockative.mock
import io.mockative.once
import io.mockative.verify
import io.mockative.given
import kotlinx.coroutines.test.runTest
import org.junit.Test
import java.nio.file.Paths
Expand All @@ -32,7 +32,9 @@ class ProteusClientProviderTest {
try {
proteusClientProvider.getOrCreate()
} catch (e: ProteusStorageMigrationException) {
coVerify { arrangement.proteusMigrationRecoveryHandler.clearClientData(any()) }.wasInvoked(once)
verify(arrangement.proteusMigrationRecoveryHandler)
.coroutine { clearClientData(any()) }
.wasInvoked(exactly = once)
}
}

Expand All @@ -45,7 +47,10 @@ class ProteusClientProviderTest {
val proteusMigrationRecoveryHandler = mock(ProteusMigrationRecoveryHandler::class)

init {
every { passphraseStorage.getPassphrase(any()) }.returns("passphrase")
given(passphraseStorage)
.suspendFunction(passphraseStorage::getPassphrase)
.whenInvokedWith(any())
.thenReturn("passphrase")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.wire.kalium.logic.feature.client
import com.wire.kalium.logic.data.logout.LogoutReason
import com.wire.kalium.logic.feature.auth.LogoutUseCase
import io.mockative.Mock
import io.mockative.coVerify
import io.mockative.mock
import io.mockative.once
import io.mockative.verify
import kotlinx.coroutines.test.runTest
import org.junit.Test

Expand All @@ -21,7 +21,9 @@ class ProteusMigrationRecoveryHandlerTest {
proteusMigrationRecoveryHandler.clearClientData(clearLocalFiles)

// then
coVerify { arrangement.logoutUseCase(LogoutReason.MIGRATION_TO_CC_FAILED, true) }.wasInvoked(once)
verify(arrangement.logoutUseCase)
.coroutine { invoke(LogoutReason.MIGRATION_TO_CC_FAILED, true) }
.wasInvoked(exactly = once)
}

private class Arrangement {
Expand Down

0 comments on commit 0f5b884

Please sign in to comment.