use crate::lookout::source::{HostSample, Local};
use crate::lookout::tail::Tail;
use shep_core::paths::ShepPaths;
use std::path::Path;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
pub(super) fn test_paths(home: &Path) -> ShepPaths {
let home_str = home.to_string_lossy().into_owned();
ShepPaths::resolve(&|key| (key == "SHEP_HOME").then(|| home_str.clone()), home)
}
#[derive(Clone, Default)]
pub(super) struct FakeLocal {
pub(super) sample: Option<HostSample>,
pub(super) hosts: Arc<AtomicUsize>,
pub(super) tails: Arc<AtomicUsize>,
}
impl Local for FakeLocal {
fn host(&mut self) -> Option<HostSample> {
self.hosts.fetch_add(1, Ordering::Relaxed);
self.sample
}
fn tail(&mut self, _out: Option<&Path>, _err: Option<&Path>) -> Tail {
self.tails.fetch_add(1, Ordering::Relaxed);
Tail::default()
}
}