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

Copy Markdown View Source

Reusable ExUnit support for independent Jido.Chat.Adapter packages.

Use this module in an adapter test module. It adds baseline tests for the capability matrix and stable unsupported results. It also imports the canonical factories and shared assertions.

defmodule MyAdapter.ConformanceTest do
  use Jido.Chat.AdapterTestKit, adapter: MyAdapter, async: true
end

Provider-specific tests can use capability_test/3. The test body runs only when the adapter declares the capability as :native or :fallback.

Summary

Functions

Adds provider-free adapter conformance tests and shared test helpers.

Defines a provider test that runs only when the adapter supports a capability.

Returns true when a capability is native or has a core fallback.

Functions

__using__(opts)

(macro)
@spec __using__(keyword()) :: Macro.t()

Adds provider-free adapter conformance tests and shared test helpers.

capability_test(capability, description, list)

(macro)
@spec capability_test(atom(), String.t(), keyword()) :: Macro.t()

Defines a provider test that runs only when the adapter supports a capability.

capability_test :edit_message, "normalizes the provider edit result" do
  result = Jido.Chat.Adapter.edit_message(@adapter, "room", "message", "new text")
  assert_capability_result(@adapter, :edit_message, result)
end

supported?(adapter, capability)

@spec supported?(module(), atom()) :: boolean()

Returns true when a capability is native or has a core fallback.