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: HttpRequest?, val respondWith: HttpResponse? = null)

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

Link copied to clipboard
data class RequestComparands(val expected: HttpRequest?, val actual: HttpRequest)

Actual and expected HttpRequest pair

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

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 (ExecutionContext, HttpRequest) -> HttpCall = { _, request -> val resp = HttpResponse(HttpStatusCode.OK, Headers.Empty, HttpBody.Empty) val now = Instant.now() HttpCall(request, resp, now, now) }): HttpClientEngine

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