Skip to content

Compatibility with Arrowopensavvy.prepared.compat.arrow.coroutinesTestResourceScope

TestResourceScope

interface TestResourceScope : ResourceScope, TestDsl

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

environment

abstract val environment: TestEnvironment

Functions

autoClose

open fun <A> autoClose(acquire: () -> A, release: (A, Throwable?) -> Unit): A

bind

open suspend fun <A> Resource<A>.bind(): A

immediate

open suspend fun <T> PreparedProvider<T>.immediate(name: String): T

install

@IgnorableReturnValue
open fun <A : AutoCloseable> install(autoCloseable: A): A
open suspend fun <A> install(acquire: suspend AcquireStep.() -> A, release: suspend (A, ExitCase) -> Unit): A

install

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.

invoke

open suspend operator fun <T> Prepared<T>.invoke(): T

onClose

open override fun onClose(release: (Throwable?) -> Unit)

onRelease

abstract infix fun onRelease(release: suspend (ExitCase) -> Unit)

release

open infix suspend fun <A> Resource<A>.release(release: suspend (A) -> Unit): A

releaseCase

open infix suspend fun <A> Resource<A>.releaseCase(release: suspend (A, ExitCase) -> Unit): A

resourceScope

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