Skip to content

Commit

Permalink
Making address and port configurable (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmerinojimenez authored Apr 3, 2023
1 parent 0b96a47 commit f6a2dc3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mock/src/main/java/com/telefonica/mock/MockApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit f6a2dc3

Please sign in to comment.