Package-level declarations

Types

Link copied to clipboard
interface CallAsserter

Asserts equality between two HttpRequest instances. Implementations of this interface are free to choose criteria for the equality assertion.

Link copied to clipboard
Link copied to clipboard
data class MockRoundTrip(val expected: <Error class: unknown class>?, val respondWith: <Error class: unknown class>? = null)

An expected HttpRequest with the response that should be returned by the engine

Link copied to clipboard
class RecordingEngine(wrapped: <Error class: unknown class>)

An HttpClientEngine implementation that can be used to record requests and responses from a "live" connection by wrapping an existing engine. This is useful for capturing actual responses from a service, dumping them to json via toJson and then later being able to replay them as part of a test connection (see TestConnection.fromJson).

Link copied to clipboard
data class RequestComparands(val expected: <Error class: unknown class>?, val actual: <Error class: unknown class>)

Actual and expected HttpRequest pair

Link copied to clipboard
class TestConnection(expected: List<MockRoundTrip> = emptyList())

TestConnection implements aws.smithy.kotlin.runtime.http.engine.HttpClientEngine with canned responses. For each expected request it will capture the actual and respond with the pre-configured response (or a basic 200-OK with an empty body if none was configured).

Link copied to clipboard
abstract class TestWithLocalServer

Spin up a local server using ktor-server to test real requests against. This can used in integration tests where mocking an HTTP client engine is difficult.

Functions

Link copied to clipboard

Invoke block with the given builder and construct a new TestConnection

Link copied to clipboard
fun TestEngine(name: String = "test", roundTripImpl: suspend (<Error class: unknown class>, <Error class: unknown class>) -> <Error class: unknown class> = { _, request -> val resp = HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.Empty) val now = Instant.now() HttpCall(request, resp, now, now) }): <Error class: unknown class>

A simplistic HttpClientEngine suitable for integration testing. This engine yields a hardcoded HttpClientEngineConfig.Default for its configuration.