Assertions shared by LlmCall.Codec.Conformance and
LlmCall.Media.Conformance.
Test support, not a runtime dependency: it imports ExUnit.Assertions and is
meant to be called from a test.
Summary
Functions
Asserts that every part is a canonical content struct.
Asserts that a decoded error is a canonical LlmCall.Error.
Asserts that info/0 returns well-formed codec metadata.
Asserts that a decoded completion response is canonical.
Asserts that a stream event uses the canonical type union and its matching delta.
Asserts that usage is nil or canonical, with non-negative integer counts.
The header names a codec must never emit (the transport adds them).
Functions
@spec assert_content_parts([LlmCall.Content.part()], String.t()) :: :ok
Asserts that every part is a canonical content struct.
A provider-specific map in content means the codec leaked its wire shape into
the IR instead of mapping it.
@spec assert_error(LlmCall.Error.t() | term(), String.t()) :: :ok
Asserts that a decoded error is a canonical LlmCall.Error.
The status is always nil — only the transport knows the HTTP status — and a
provider code is normalized to a string or nil, whatever the wire type was.
A codec never sets reason either; it is the client's structured transport
reason.
@spec assert_info(module()) :: :ok
Asserts that info/0 returns well-formed codec metadata.
ir_version must be 1; version is a wire version string or nil.
@spec assert_response(LlmCall.Response.t() | term(), String.t()) :: :ok
Asserts that a decoded completion response is canonical.
content holds canonical parts, stop_reason is in the closed union, usage
is canonical or nil, and raw is a map or nil — never a second response
model.
@spec assert_stream_event(LlmCall.StreamEvent.t() | term(), String.t()) :: :ok
Asserts that a stream event uses the canonical type union and its matching delta.
The index is a non-negative integer or nil. A content event carries the delta
its type names (:text_delta → StreamDelta.Text, and so on); a
:message_delta carries either the normalized delta or StreamDelta.Raw for an
unmapped provider field, which is how a codec preserves unknown data. A
structural event carries none.
@spec assert_usage(LlmCall.Usage.t() | term(), String.t()) :: :ok
Asserts that usage is nil or canonical, with non-negative integer counts.
@spec credential_headers() :: [String.t()]
The header names a codec must never emit (the transport adds them).