use std::ops::Deref;
use std::sync::Arc;
use crate::platform::services::PlatformService;
pub struct TestPlatform {
platform: Arc<PlatformService>,
_root: tempfile::TempDir,
}
impl Deref for TestPlatform {
type Target = Arc<PlatformService>;
fn deref(&self) -> &Self::Target {
&self.platform
}
}
pub fn test_platform() -> TestPlatform {
let root = tempfile::tempdir().expect("tempdir");
let mut config = crate::platform::model::PlatformConfig::default();
config.data_root = root.path().join("platform");
let platform = Arc::new(PlatformService::from_config(config).expect("platform"));
TestPlatform { platform, _root: root }
}