WorkerSink

class WorkerSink<T>(name: String, type: KClass<*>) : Worker<T> (source)

Implementation of Worker for integration tests (using launchForTestingFromStartWith or launchForTestingFromStateWith) that need to simply push values into the worker from the test.

Instances of this class are considered equivalent if they have matching type and name.

These workers can not be run concurrently – they may only be run by a single workflow at a time, although they may be run multiple times sequentially. The Flow returned by run will throw an exception if it is collected more than once concurrently.

Parameters

name

String used to distinguish this worker from other WorkerSinks being ran by the same workflow. Used to implement doesSameWorkAs, see the kdoc on that method for more information.

Constructors

Link copied to clipboard
constructor(name: String, type: KClass<*>)

Functions

Link copied to clipboard
open override fun doesSameWorkAs(otherWorker: Worker<*>): Boolean
Link copied to clipboard
open override fun run(): Flow<T>
Link copied to clipboard
fun send(value: T)
Link copied to clipboard
fun <T> Worker<T>.test(timeoutMs: Long = DEFAULT_TIMEOUT_MS, block: suspend WorkerTester<T>.() -> Unit)

Test a Worker by defining assertions on its output within block.

Link copied to clipboard
open override fun toString(): String