Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-18 13:04:21 +04:00
parent dcb8b474cf
commit 024a37517d
74 changed files with 103 additions and 131 deletions

View file

@ -1,19 +0,0 @@
package com.tangem.common.test.utils
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher
@OptIn(ExperimentalCoroutinesApi::class)
fun <T> TestScope.getEmittedValues(flow: Flow<T>): List<T> {
val values = mutableListOf<T>()
backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) {
flow.toList(values)
}
return values
}

View file

@ -1,11 +0,0 @@
package com.tangem.common.test.utils
import org.junit.jupiter.params.provider.MethodSource
/**
[REDACTED_AUTHOR]
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@MethodSource("provideTestModels")
annotation class ProvideTestModels

View file

@ -1,47 +0,0 @@
package com.tangem.common.test.utils
import arrow.core.Either
import arrow.core.None
import arrow.core.Option
import com.google.common.truth.Truth
fun <B> assertEither(actual: Either<Throwable, B>, expected: Either<Throwable, B>) {
actual
.onRight { Truth.assertThat(actual).isEqualTo(expected) }
.onLeft { throwable ->
val expectedError = expected.leftOrNull() ?: error("Actual is Either.Left: $throwable")
Truth.assertThat(throwable).isInstanceOf(expectedError::class.java)
Truth.assertThat(throwable).hasMessageThat().isEqualTo(expectedError.message)
}
}
fun assertEitherRight(actual: Either<Throwable, Unit>) {
actual
.onRight { Truth.assertThat(actual).isEqualTo(Either.Right(Unit)) }
.onLeft {
error("Actual is Either.Left: $it")
}
}
@Suppress("NullableToStringCall")
fun <B> assertEitherLeft(actual: Either<Throwable, B>, expected: Throwable) {
actual
.onRight { error("Actual is Either.Right: $it") }
.onLeft { throwable ->
Truth.assertThat(throwable::class.java).isEqualTo(expected::class.java)
Truth.assertThat(throwable).hasMessageThat().isEqualTo(expected.message)
}
}
fun <B> assertNone(actual: Option<B>) {
Truth.assertThat(actual).isEqualTo(None)
}
fun <B> assertSome(actual: Option<B>, expected: B) {
actual
.onNone { error("Actual is None") }
.onSome {
Truth.assertThat(it).isEqualTo(expected)
}
}