I have one question. I'm using the following function together with the Scala cats Library.
def process(
client: Resource[IO, HttpClient] = HttpClientFactory.createClient()
): IO[Long] =
client.use(httpClient => {
for {
files <- IO { getFiles() }
placeMarkers <- IO { sendFile(client) }
} yield placeMarkers
})
Now I want to test this code with unit tests and I want to mock the httpClient. I was trying something like this but it does not work:
val resourceIOMock = mock[Resource[IO, HttpClient]]
val httpMock = mock[HttpClient]
doReturn(httpMock).when(resourceIOMock).use(any())
this does not work because of the Mathcers any(). I really don't know how to pass my mock there which then can be configured as needed. From what I see the code never enters the for loop. Can someone help? Thx