TestResourceScope

A scope to combine Arrow's ResourceScope with Prepared's TestDsl.

This scope is used within tests that declare resources.

Resources declared in this scope are released at the end of the test.

Instances of this type can be obtained:

Additionally:

  • The install functions allows binding a resource directly within a test.

  • The asPrepared function converts a Resource into a Prepared value, Prepared's equivalent concept.

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open fun <A> autoClose(acquire: () -> A, release: (A, Throwable?) -> Unit): A
Link copied to clipboard
open suspend fun <A> Resource<A>.bind(): A
Link copied to clipboard
open suspend fun <T> PreparedProvider<T>.immediate(name: String): T
Link copied to clipboard
open fun <A : AutoCloseable> install(autoCloseable: A): A
open suspend fun <A> install(acquire: suspend AcquireStep.() -> A, release: suspend (A, ExitCase) -> Unit): A
Link copied to clipboard
suspend fun <A> TestDsl.install(resource: Resource<A>): A

Installs a Resource into the test's lifecycle scope.

suspend fun <A> TestDsl.install(acquire: suspend TestDsl.() -> A, release: suspend TestDsl.(A, ExitCase) -> Unit): A

Installs an acquire action and its matching release action.

Link copied to clipboard
open suspend operator fun <T> Prepared<T>.invoke(): T
Link copied to clipboard
open override fun onClose(release: (Throwable?) -> Unit)
Link copied to clipboard
abstract infix fun onRelease(release: suspend (ExitCase) -> Unit)
Link copied to clipboard
open infix suspend fun <A> Resource<A>.release(release: suspend (A) -> Unit): A
Link copied to clipboard
open infix suspend fun <A> Resource<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): A
Link copied to clipboard

Allows accessing the test lifecycle as an Arrow's ResourceScope.