Customer experience
Go
Python
Java
repost-client-test provides StubTransport, a recording, no-network transport. Set it via the transport property, enqueue responses, send, and assert on the recorded request. The Authorization header is stripped from recordings; the idempotency key travels as the Idempotency-Key header:
val transport = StubTransport().enqueueResponse(
202,
"{\"id\":\"msg_1\",\"type\":\"order.created\",\"customerId\":\"customer-123\"," +
"\"timestamp\":\"1970-01-01T00:00:00.000Z\"}",
)
RepostClient {
apiKey = "test-key"
this.transport = transport
maxAttempts = 1
}.use { repost ->
val result = repost.webhooks.order.created("customer-123") { id = "order-123" }
check(result.id == "msg_1")
}
check(String(transport.requests[0].bodyBytes, Charsets.UTF_8).contains("\"id\":\"order-123\""))Add repost-client-test in test scope. It also ships enqueueFailure, enqueuePending for deferred completion, a RecordingObserver, a NoNetworkGuard, and deterministic clocks and generators.
Continue#
On This Page
Continue