EventBus 订阅 helper — 让调用方进程接收指定 session 的所有 {:cmdc_event, sid, ...} 消息。
与 CMDCTest.Assertions 配合使用:
use ExUnit.Case
import CMDCTest.Assertions
test "..." do
{:ok, session} = CMDC.create_agent(...)
:ok = CMDCTest.EventCapture.start_capture(session)
CMDC.prompt(session, "go")
assert_event_emitted(session, :agent_end)
end无需手动 stop_capture:测试进程退出时 EventBus 订阅自动清理。
Summary
Functions
@spec start_capture(CMDC.session()) :: :ok | {:error, term()}
在当前进程订阅指定 session 的所有事件。
参数
session— pid 或 session_id 字符串
返回 :ok 或 {:error, :invalid_session}。
@spec stop_capture(CMDC.session()) :: :ok | {:error, term()}
在当前进程取消订阅指定 session 的所有事件。