use std::sync::Arc;

use lash_core::PluginHost;

fn tool_names(session: &lash_core::PluginSession) -> Vec<String> {
    session
        .resolved_tool_catalog("root")
        .expect("tool catalog")
        .tool_names()
        .as_ref()
        .clone()
}

#[test]
fn standard_protocol_owns_batch_not_processess() {
    let session = PluginHost::new(vec![Arc::new(
        lash_protocol_standard::StandardProtocolPluginFactory,
    )])
    .build_session("root", None)
    .expect("session");

    let names = tool_names(&session);
    assert!(names.contains(&"batch".to_string()));
    assert!(!names.contains(&"list_process_handles".to_string()));
    assert!(!names.contains(&"cancel_process".to_string()));
}

#[test]
fn processess_are_composed_with_standard_protocol() {
    let session = PluginHost::new(vec![
        Arc::new(lash_plugin_process_controls::SessionProcessAdminPluginFactory::new()),
        Arc::new(lash_tools::shell::StandardShellPluginFactory::new()),
        Arc::new(lash_protocol_standard::StandardProtocolPluginFactory),
    ])
    .build_session("root", None)
    .expect("session");

    let names = tool_names(&session);
    assert!(names.contains(&"batch".to_string()));
    assert!(names.contains(&"list_process_handles".to_string()));
    assert!(names.contains(&"cancel_process".to_string()));
}
