use std::sync::{Arc, Mutex};
use crate::session_manager::{ManagedError, ManagedTmuxDriver};
pub(crate) struct FakeTmux {
pub(crate) sends: Mutex<Vec<(String, String)>>,
}
impl FakeTmux {
pub(crate) fn new() -> Arc<Self> {
Arc::new(Self {
sends: Mutex::new(Vec::new()),
})
}
}
impl ManagedTmuxDriver for FakeTmux {
fn create_session(&self, _name: &str, _workdir: &str) -> Result<(), ManagedError> {
Ok(())
}
fn kill_session(&self, _name: &str) -> Result<(), ManagedError> {
Ok(())
}
fn send_line(&self, name: &str, text: &str) -> Result<(), ManagedError> {
self.sends
.lock()
.expect("FakeTmux send log mutex poisoned")
.push((name.to_owned(), text.to_owned()));
Ok(())
}
fn capture(&self, _name: &str, _lines: u32) -> Result<String, ManagedError> {
Ok(String::new())
}
fn list_sessions(&self) -> Result<Vec<String>, ManagedError> {
Ok(Vec::new())
}
fn session_exists(&self, _name: &str) -> bool {
false
}
}