testing library

Test utilities for degenerate-generated API clients.

import 'package:degenerate_runtime/testing.dart';

Classes

ApiClient
The contract any HTTP client must satisfy.
ApiConfig
Configuration for the generated API classes.
ApiException<T, E>
Network-level failure (DNS, timeout, connection refused).
ApiMultipartField
A single field in a multipart/form-data request.
ApiMultipartFileField
A binary file field in a multipart/form-data request.
ApiMultipartTextField
A text field in a multipart/form-data request.
ApiOAuthFlow
ApiParseException<T, E>
The server returned a response but it could not be deserialized.
ApiQueryParameter
An outgoing API request.
ApiRequest
ApiResponse
A raw API response before deserialization.
ApiResult<T, E>
The result of an API operation.
ApiSecurityRequirement
ApiSecurityScheme
ApiSuccess<T, E>
AuthInterceptor
Middleware that adds an Authorization header and optionally refreshes the token on 401 responses.
CancelToken
A token that can be used to cancel one or more API requests.
Interceptor
Middleware that can inspect/modify requests and responses.
LoggingInterceptor
Middleware that logs requests and responses.
OneOf2<A, B>
OneOf3<A, B, C>
OneOf4<A, B, C, D>
OneOf5<A, B, C, D, E>
OneOf6<A, B, C, D, E, F>
OneOf7<A, B, C, D, E, F, G>
OneOf8<A, B, C, D, E, F, G, H>
OneOf9<A, B, C, D, E, F, G, H, I>
RecordingClient
A test ApiClient that records requests and returns canned responses.
RequestOptions
Per-request overrides for timeout, headers, and cancellation.
RetryInterceptor
Middleware that retries failed requests with exponential backoff.
SseEvent
A parsed Server-Sent Event.
StreamedApiResponse
A streaming API response where the body is delivered as a byte stream.

Mixins

ApiExecutor
Shared execution logic for generated API classes.

Functions

buildInterceptorChain({required List<Interceptor> interceptors, required Handler terminal}) Handler
Build a middleware chain from a list of interceptors and a terminal handler.
listEquals<T>(List<T>? a, List<T>? b) bool
Element-wise equality check for lists.
mapEquals<K, V>(Map<K, V>? a, Map<K, V>? b) bool
Entry-wise equality check for maps.
parseJsonlStream(Stream<List<int>> byteStream) Stream<String>
Parses a byte stream of newline-delimited JSON (JSONL/NDJSON) into individual JSON strings, one per non-empty line.
parseSseStream(Stream<List<int>> byteStream, {String? doneSignal = '[DONE]'}) Stream<SseEvent>
Parse a byte stream of Server-Sent Events into SseEvents.

Typedefs

Handler = Future<ApiResponse> Function(ApiRequest request)
A function that processes a request and returns a response.
RetryRandom = double Function()
RetrySleep = Future<void> Function(Duration delay)

Exceptions / Errors

ApiError<T, E>
ApiStreamError
Thrown when a streaming request receives a non-2xx response.
CancelledException
Thrown when a request is cancelled via CancelToken.