Skip to content

Commit

Permalink
refactor: mock dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
precious-ossai-cko committed Jun 5, 2024
1 parent e10bb76 commit f16ffe4
Show file tree
Hide file tree
Showing 2 changed files with 319 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ internal class TokenRepositoryImpl(
NonCancellable,
)

@VisibleForTesting
var dispatcher = Dispatchers.IO

@Suppress("TooGenericExceptionCaught")
override fun sendCardTokenRequest(cardTokenRequest: CardTokenRequest) {
var response: NetworkApiResponse<TokenDetailsResponse>
Expand Down Expand Up @@ -130,7 +133,7 @@ internal class TokenRepositoryImpl(
when (tokenResult) {
is TokenResult.Success -> {
try {
withContext(Dispatchers.IO) {
withContext(dispatcher) {
riskSdkUseCase.execute(TokenResult.Success(tokenResult.result.token))
}
} catch (exception: Exception) {
Expand Down Expand Up @@ -211,7 +214,7 @@ internal class TokenRepositoryImpl(
) {
when (tokenResult) {
is TokenResult.Success -> try {
withContext(Dispatchers.IO) {
withContext(dispatcher) {
riskSdkUseCase.execute(TokenResult.Success(tokenResult.result.token))
}
} catch (exception: Exception) {
Expand Down
Loading

0 comments on commit f16ffe4

Please sign in to comment.