Skip to content

Commit

Permalink
Add an artifical delay
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Dec 4, 2024
1 parent 725d6e1 commit 309517e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.woocommerce.android.apifaker

import android.util.Log
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.MediaType.Companion.toMediaType
Expand All @@ -11,6 +9,8 @@ import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import javax.inject.Inject

private const val ARTIFICIAL_DELAY_MS = 500L

internal class ApiFakerInterceptor @Inject constructor(
private val apiFakerConfig: ApiFakerConfig,
private val endpointProcessor: EndpointProcessor
Expand All @@ -32,6 +32,7 @@ internal class ApiFakerInterceptor @Inject constructor(

return if (fakeResponse != null) {
Log.d(LOG_TAG, "Matched request: ${chain.request().url}:\nSending Mocked Response: $fakeResponse")
Thread.sleep(ARTIFICIAL_DELAY_MS)
Response.Builder()
.request(request)
.protocol(Protocol.HTTP_1_1)
Expand Down

0 comments on commit 309517e

Please sign in to comment.