Brais Gabin
03/02/2022, 4:47 PMHttpResponse? I would like to use it to test a function that receives an HttpResponse and returns a Result. I know that I could use MockEngine to create a HttpResponse but it feels too much. I'm assuming that HttpResponse is something similar as Response in Retrofit. And there I could use Response.error() or Response.success() to create fakes.Aleksei Tirman [JB]
03/02/2022, 5:10 PMBrais Gabin
03/02/2022, 5:30 PMHttpClientCall because its constructor is internal.Javier
03/02/2022, 9:57 PMHttpClientCall was not internal, @Aleksei Tirman [JB] is it possible to change it to public?Aleksei Tirman [JB]
03/03/2022, 7:20 AMe5l
03/03/2022, 7:21 AMBrais Gabin
03/03/2022, 11:15 AM_< I make it work with mockk but now my first test needs 2 seconds to finish. I'll open an issue to find a better way,
internal inline fun <reified T : Any> fakeHttpResponse(
status: HttpStatusCode,
value: T,
): HttpResponse {
return mockk {
every { this@mockk.status } returns status
coEvery { receive<T>() } returns value
}
}Javier
03/03/2022, 11:40 AMBrais Gabin
03/03/2022, 11:41 AMJavier
03/03/2022, 11:41 AMBrais Gabin
03/03/2022, 11:41 AMJavier
03/03/2022, 11:41 AMJavier
03/07/2022, 11:27 AMe5l
03/07/2022, 11:28 AMJavier
03/07/2022, 11:28 AMJavier
03/07/2022, 11:29 AM