Jido.Chat.AdapterTestKit.Assertions (Jido Chat v1.2.0)

Copy Markdown View Source

Shared ExUnit assertions for adapter contract tests.

These functions use only the public adapter API and canonical Jido.Chat types. They do not need a provider SDK.

Summary

Functions

Asserts that capability statuses and native callbacks are coherent.

Asserts the normalized result shape for a declared capability.

Asserts JSON-safe serialization and revival for a typed value.

Asserts canonical media fields and returns the media value.

Asserts and returns a stable external message identifier.

Asserts a normalized Jido.Chat.Response result with a message identifier.

Asserts unsupported declarations are coherent without calling provider operations.

Asserts that a webhook request becomes a typed event envelope.

Functions

assert_capability_coherence(adapter)

@spec assert_capability_coherence(module()) :: Jido.Chat.CapabilityMatrix.t()

Asserts that capability statuses and native callbacks are coherent.

assert_capability_result(adapter, capability, result)

@spec assert_capability_result(module(), atom(), term()) :: term()

Asserts the normalized result shape for a declared capability.

Use this in capability_test/3 blocks after the provider operation runs.

assert_json_round_trip(value)

@spec assert_json_round_trip(struct()) :: struct()

Asserts JSON-safe serialization and revival for a typed value.

assert_media(media, expected \\ [])

@spec assert_media(
  Jido.Chat.Media.t(),
  keyword()
) :: Jido.Chat.Media.t()

Asserts canonical media fields and returns the media value.

assert_message_identifier(value)

@spec assert_message_identifier(
  Jido.Chat.Response.t()
  | Jido.Chat.Message.t()
  | Jido.Chat.Incoming.t()
) ::
  String.t()

Asserts and returns a stable external message identifier.

assert_normalized_response(result)

@spec assert_normalized_response(term()) :: Jido.Chat.Response.t()

Asserts a normalized Jido.Chat.Response result with a message identifier.

assert_unsupported_operations(adapter)

@spec assert_unsupported_operations(module()) :: :ok

Asserts unsupported declarations are coherent without calling provider operations.

assert_webhook_event(adapter, request, opts \\ [])

@spec assert_webhook_event(module(), Jido.Chat.WebhookRequest.t() | map(), keyword()) ::
  Jido.Chat.EventEnvelope.t()

Asserts that a webhook request becomes a typed event envelope.