use std::path::PathBuf;
use std::sync::Arc;
use algocline_core::AppDir;
use super::config::AppConfig;
use super::resolve::SearchPath;
use super::AppService;
pub(super) async fn make_app_service() -> AppService {
make_app_service_with_search_paths(vec![]).await
}
pub(super) async fn make_app_service_with_search_paths(
search_paths: Vec<SearchPath>,
) -> AppService {
let tmp = tempfile::tempdir().expect("test tempdir");
let root = tmp.path().to_path_buf();
std::mem::forget(tmp);
make_app_service_at_with_search_paths(root, search_paths).await
}
pub(super) async fn make_app_service_at(root: PathBuf) -> AppService {
make_app_service_at_with_search_paths(root, vec![]).await
}
pub(super) async fn make_app_service_at_with_search_paths(
root: PathBuf,
search_paths: Vec<SearchPath>,
) -> AppService {
let executor = Arc::new(
algocline_engine::Executor::new(vec![])
.await
.expect("executor"),
);
let log_config = AppConfig::default().with_app_dir(root).with_log_disabled();
AppService::new(executor, log_config, search_paths)
}
pub(super) fn test_app_dir(root: &std::path::Path) -> AppDir {
AppDir::new(root.to_path_buf())
}