Skip to main content
github.com/repost-sh/repost-go/reposttest drives the real generated method tree, validation, serialization, retry loop, response parsing, and observers without opening a network connection. It provides a scripted transport, deterministic generators, a manual clock and scheduler, retry entropy, and a recording observer.

Build a deterministic client

Requests returns deep copies in capture order. Each record contains the URL, serialized body, attempt number, idempotency key, connect timeout, attempt timeout, and safe headers. The Authorization header is always removed before storage. A scripted 202 response must contain the same event type, customer ID, and timestamp that the request sent. This matches publish API response validation and catches stale test fixtures.

Script failures and pending attempts

ScriptedTransport consumes one scripted result per attempt:
The committed argument tells the runtime whether request bytes may have left. Use false for a definite NOT_SENT failure and true when the expected outcome is ambiguous. EnqueuePending returns a ControlledResponse. Complete it with a response, fail it with a classified transport error, or cancel it after the send is in flight. The first settlement wins. Script exhaustion is a test defect and becomes a non-retryable custom-transport failure instead of falling through to the network.

Drive retry timing

Use one ManualClock for monotonic and wall time, and pair it with ManualScheduler. The scheduler blocks retry waits until the test advances the clock.
Use SequenceEntropy when you need exact jitter values. SequenceGenerators and SequenceIdempotencyKeys provide concurrency-safe FIFO values. Sequence helpers fail on exhaustion so unexpected generator or retry calls cannot pass silently.

Assert lifecycle events

RecordingObserver exposes immutable event snapshots and context-aware wait methods:
For a one-attempt success, assert operation.start, attempt.start, attempt.end, then operation.end. Use AwaitNext when the test needs to react to a specific event before allowing an attempt to settle. No process-wide network guard is needed. A client configured with ScriptedTransport has no path to the built-in HTTP transport.

Continue

Reliability

Choose the delivery states and error codes to exercise.

Observability

Understand the events recorded by the test observer.

Frameworks

Share and close one client in a Go service.