preparedResource
Declares a prepared value that contains Arrow Resources.
The resources are released at the end of the test.
Example
val userProcessor: Resource<UserProcessor> = resource({
UserProcessor().also { it.start() }
}) { p, _ -> p.shutdown() }
val dataSource: Resource<DataSource> = resource({
DataSource().also { it.connect() }
}) { ds, exitCase ->
println("Releasing $ds with exit: $exitCase")
withContext(Dispatchers.IO) { ds.close() }
}
// Note the 'by'!
val service by preparedResource {
Service(dataSource.bind(), userProcessor.bind())
}
test("Some kind of test") {
service().createEntity("…")
}Content copied to clipboard
External resources
See also
Overview of Prepared and Arrow's compatibility.