//! A fixture binds the self streams and console streams the way `run` does,
//! without the publisher thread: the fixture pumps the console itself.
use super::ConnectionSupervisor;
use crate::ServerError;
use crate::config::types::ServerConfig;
use crate::server::ShutdownHandle;
use crate::server::connection::LiminalConnectionServices;
use crate::server::self_streams::sink::SelfStreams;
use std::sync::Arc;
/// The bound streams a fixture holds; no thread pumps them.
pub struct ConsoleForTests {
_streams: Option<Arc<SelfStreams>>,
}
impl ConnectionSupervisor {
/// Binds the self streams and console streams through the bootstrap
/// `run` uses, so a fixture's console taps are registered by the
/// production path. No publisher thread starts: a tap fills and evicts
/// until the fixture pumps it. Without a `[participant]` section nothing
/// is bound, as in production.
///
/// # Errors
/// The same failures `run` names when the streams cannot bind.
pub fn bind_console_for_tests(
&self,
services: &Arc<LiminalConnectionServices>,
config: &ServerConfig,
shutdown: &ShutdownHandle,
) -> Result<ConsoleForTests, ServerError> {
crate::server::runtime::bind_self_streams(services, self, config, shutdown)
.map(|streams| ConsoleForTests { _streams: streams })
}
}