Documentation
¶
Overview ¶
Package idempotencytest provides a reusable conformance suite for implementations of idemhttp.Store. Any implementation — in-memory (Batch 1) or Redis-backed (adapters/redis) — calls RunConformanceSuite to verify the full Claim/Record/Release/TTL contract.
The suite is a plain .go file (not _test.go) so it can be imported by test packages in other layers without being stripped from the build graph.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRecordedResponse ¶
BuildRecordedResponse constructs a minimal RecordedResponse (Content-Type: application/json) via the only package-external construction path, idemhttp.UnmarshalRecordedResponse. It is exported so cross-package Store integration tests — e.g. the adapters/redis full-assembly cross-pod replay test (#1449) — build replay fixtures from the same single source as this conformance suite, instead of re-deriving the unexported recordedResponseDTO wire shape a third time.
func RunConformanceSuite ¶
RunConformanceSuite runs the full Store conformance suite against the supplied factory. Every subtest is registered as a t.Run so individual cases can be filtered with -run.
Types ¶
type Factory ¶
type Factory func(t *testing.T) (store idemhttp.Store, adv TimeAdvancer, cleanup func())
Factory constructs a fresh Store, a TimeAdvancer that controls the TTL clock for that store, and a cleanup function. cleanup is safe to call once and must be deferred by the caller.
The TimeAdvancer returned by the factory is the SAME clock the Store uses internally (for MemStore: a *clockmock.FakeClock wrapper; for Redis: a real-sleep wrapper), so tests can expire leases without busy-waiting.
type TimeAdvancer ¶
TimeAdvancer allows the conformance suite to move time forward past a TTL boundary without depending on the specific clock implementation used by a given Store backend.
- For MemStore, the factory wraps [clockmock.FakeClock.Advance].
- For Redis-backed stores, the factory uses a real time.Sleep so Redis server-side PX expiry fires naturally.
AdvancePast advances time by at least d so that any TTL of exactly d has already expired. Implementations must block until the advance is complete.