Package-level declarations

Types

Link copied to clipboard
class FakeAuthorizationProvider(initialToken: String? = "token", refreshedToken: String? = "refreshed-token", refreshSucceeds: Boolean = true) : AuthorizationProvider

A scriptable AuthorizationProvider for tests. Tracks how many times a refresh was requested and can simulate refresh success or failure.

Link copied to clipboard
class FakeReachabilityGate(reachable: Boolean = true) : ReachabilityGate

A controllable ReachabilityGate for tests. Starts reachable (default true, so awaitReachable returns immediately); flip it with setReachable to make a pending awaitReachable resume. awaitCount records how many times the gate was awaited.

Link copied to clipboard

A NetworkEventListener that records every emitted NetworkEvent for assertions.

Link copied to clipboard
class RecordingRetryPolicy(delegate: RetryPolicy = DefaultRetryPolicy()) : RetryPolicy

A RetryPolicy that records every decision and forwards to delegate, so tests can assert how many retries happened, for which errors, and with what delays. Defaults to wrapping a DefaultRetryPolicy.

Functions

Link copied to clipboard
fun MockRequestHandleScope.jsonResponse(body: String, status: HttpStatusCode = HttpStatusCode.OK): HttpResponseData

Responds with a JSON body and the given status.

Link copied to clipboard
fun mockNetworkClient(json: Json = DefaultKenworkJson, authorizationProvider: AuthorizationProvider? = null, maxAuthRefreshAttempts: Int = 1, retryDelayMillis: Long = 0, retryPolicy: RetryPolicy = RetryPolicy.None, reachabilityGate: ReachabilityGate? = null, eventListener: NetworkEventListener? = null, requestInterceptor: RequestInterceptor? = null, requestHeaderProvider: RequestHeaderProvider? = null, handler: suspend MockRequestHandleScope.(HttpRequestData) -> HttpResponseData): NetworkClient

Builds a NetworkClient backed by a Ktor MockEngine driven by handler. Intended for unit tests of code that depends on kenwork — no real sockets are opened.