use futures_util::StreamExt;
#[tokio::test]
async fn test_event_subscriber_stream_trait() {
let (tx, mut rx) = tokio::sync::mpsc::channel::<()>(10);
drop(tx);
let result = rx.recv().await;
assert!(
result.is_none(),
"recv should return None when sender drops"
);
let (sub, guard) = {
let agent = crate::Agent::new("claude-sonnet-4-6").max_turns(1);
agent.subscribe()
};
drop(guard);
drop(sub);
}
#[tokio::test]
async fn test_subscribe_creates_independent_channels() {
let agent = crate::Agent::new("claude-sonnet-4-6").max_turns(1);
let (mut sub1, guard1) = agent.subscribe();
let (mut sub2, guard2) = agent.subscribe();
drop(guard1);
drop(sub1);
drop(guard2);
assert!(true); }
#[tokio::test]
async fn test_cancel_guard_cleanup() {
let agent = crate::Agent::new("claude-sonnet-4-6").max_turns(1);
let (_sub, guard) = agent.subscribe();
drop(guard);
let model = agent.get_model();
assert!(
!model.is_empty(),
"Agent should still be usable after guard drops, model={model}"
);
}