Turbine

interface Turbine<T> : ReceiveTurbine<T>

A standalone Turbine suitable for usage in fakes or other external test components.

Functions

Link copied to clipboard
abstract fun add(item: T)

Add an item to the underlying Channel without blocking.

Link copied to clipboard
abstract override fun asChannel(): Channel<T>

Returns the underlying Channel. The Channel will have a buffer size of UNLIMITED.

Link copied to clipboard
abstract suspend fun awaitComplete()

Assert that the next event received was the flow completing. This function will suspend if no events have been received.

Link copied to clipboard
abstract suspend fun awaitError(): Throwable

Assert that the next event received was an error terminating the flow. This function will suspend if no events have been received.

Link copied to clipboard
abstract suspend fun awaitEvent(): Event<T>

Assert that an event was received and return it. This function will suspend if no events have been received.

Link copied to clipboard
abstract suspend fun awaitItem(): T

Assert that the next event received was an item and return it. This function will suspend if no events have been received.

Link copied to clipboard
abstract suspend fun cancel()

Cancel this ReceiveTurbine.

Link copied to clipboard
abstract suspend fun cancelAndConsumeRemainingEvents(): List<Event<T>>

Cancel this ReceiveTurbine and return any events which have already been received.

Link copied to clipboard
abstract suspend fun cancelAndIgnoreRemainingEvents()

Cancel this ReceiveTurbine and ignore any events which have already been received.

Link copied to clipboard
abstract fun close(cause: Throwable? = null)

Closes the underlying Channel. After all items have been consumed, this Turbine will yield Event.Complete if cause is null, and Event.Error otherwise.

Link copied to clipboard

Assert that all events that have occurred so far on this ReceiveTurbine have been consumed.

Link copied to clipboard
abstract fun expectMostRecentItem(): T

Returns the most recent item that has already been received. If a complete event has been received with no item being received previously, this function will throw an AssertionError. If an error event has been received, this function will throw the underlying exception.

Link copied to clipboard
abstract fun expectNoEvents()

Assert that there are no unconsumed events which have already been received.

Link copied to clipboard
operator fun <T> Turbine<T>.plusAssign(value: T)
Link copied to clipboard
abstract suspend fun skipItems(count: Int)

Assert that count item events were received and ignore them. This function will suspend if no events have been received.

Link copied to clipboard
abstract fun takeComplete()

Assert that the next event received is Event.Complete. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
abstract fun takeError(): Throwable

Assert that the next event received is Event.Error, and return the error. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
abstract fun takeEvent(): Event<T>

Assert that the next event received was non-null and return it. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.

Link copied to clipboard
abstract fun takeItem(): T

Assert that the next event received was an item and return it. This function will not suspend. On JVM and Android, it will attempt to throw if invoked in a suspending context.