From f6a2dc308775ba5a729638d4d8f1bbc8b475e993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Merino=20Jim=C3=A9nez?= Date: Mon, 3 Apr 2023 13:48:31 +0200 Subject: [PATCH] Making address and port configurable (#14) --- mock/src/main/java/com/telefonica/mock/MockApiClient.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mock/src/main/java/com/telefonica/mock/MockApiClient.kt b/mock/src/main/java/com/telefonica/mock/MockApiClient.kt index 5def65b..2d7d7f4 100644 --- a/mock/src/main/java/com/telefonica/mock/MockApiClient.kt +++ b/mock/src/main/java/com/telefonica/mock/MockApiClient.kt @@ -7,6 +7,7 @@ import okhttp3.mockwebserver.Dispatcher import okhttp3.mockwebserver.MockResponse import okhttp3.mockwebserver.MockWebServer import okhttp3.mockwebserver.RecordedRequest +import java.net.InetAddress import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -34,10 +35,10 @@ open class MockApiClient @Inject constructor( } } - suspend fun startServer() { + suspend fun startServer(inetAddress: InetAddress = InetAddress.getByName("localhost"), port: Int = 0) { withContext(coroutineDispatcher) { runCatching { - mockWebServer.start(port = 0) + mockWebServer.start(inetAddress = inetAddress, port = port) } } }