Explicit, isolated application fixtures at the Pristine transport seam.
These helpers do not replace serialization, retry classification, decoding or
semantic validation. The configured transport can never call the live API.
A scenario monitors its creating process and can be shared explicitly with
child tasks. Call verify!/1 before the owner exits, and close/1 when done.
client = TypeSafeSDK.Test.client()
client = TypeSafeSDK.Test.stub(client, urgent: {:noul, 0.9})
result = TypeSafeSDK.evaluate!(client, "synthetic example", urgent: TypeSafeSDK.noul("Urgent?"))
TypeSafeSDK.Test.verify!(client)
TypeSafeSDK.Test.close(client)Default retries are disabled. Enable the real retry policy explicitly when
using stub_sequence/2. Request history is bounded (default 1000) and contains
the actual serialized request; use synthetic data and test credentials only.
Summary
Functions
@spec client(keyword()) :: TypeSafeSDK.Client.t()
@spec close(TypeSafeSDK.Client.t()) :: :ok
@spec requests(TypeSafeSDK.Client.t()) :: list()
@spec stats(TypeSafeSDK.Client.t()) :: map()
@spec stub(TypeSafeSDK.Client.t(), map() | list(), keyword()) :: TypeSafeSDK.Client.t()
Build a fixture from the actual request, for state-dependent or synchronized application tests.
@spec stub_http_error(TypeSafeSDK.Client.t(), integer(), keyword()) :: TypeSafeSDK.Client.t()
@spec stub_models(TypeSafeSDK.Client.t(), list(), keyword()) :: TypeSafeSDK.Client.t()
Raw response escape hatch for testing malformed or future response contracts.
@spec stub_sequence(TypeSafeSDK.Client.t(), list()) :: TypeSafeSDK.Client.t()
Finite request/attempt sequence. Exhaustion fails; verify!/1 checks consumption.
Entries: {:answers, specs, opts}, {:models, models, opts},
{:http_error, status, opts}, {:transport_error, reason},
{:response, raw_body, opts}. The first, second, third and fifth accept omitted opts.
@spec stub_transport_error(TypeSafeSDK.Client.t(), term()) :: TypeSafeSDK.Client.t()
@spec verify!(TypeSafeSDK.Client.t()) :: :ok