ExUnit helpers for asserting on LangchainPrompt.Adapters.Test calls.
Import this in your test files:
import LangchainPrompt.TestAssertionsMacros
assert_adapter_called/0— asserts the adapter was called (ignores payload).assert_adapter_called/1— asserts the adapter was called and runs an assertion function on the payload.refute_adapter_called/0— asserts the adapter was NOT called.
Example
test "sends the right system prompt" do
LangchainPrompt.execute(MyPrompt, assigns)
assert_adapter_called(fn payload ->
system_msg = hd(payload.messages)
assert system_msg.role == :system
assert system_msg.content =~ "summarise"
end)
end
Summary
Functions
Asserts the test adapter was called, and optionally inspects the payload.
Asserts the test adapter was NOT called.
Functions
Asserts the test adapter was called, and optionally inspects the payload.
When called with a function, the function receives a map with:
:messages— the list ofLangchainPrompt.Messagestructs sent to the adapter:opts— the profile opts map
Asserts the test adapter was NOT called.