1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use mesk::cfg::config::{Config, Log, Loglevel, Paths, Repo};
pub fn create_test_config(temp_dir_path: &str) -> Config {
// Create a unique subdirectory for this specific test to avoid parallel execution conflicts
let unique_cache_dir = format!("{}/{}", temp_dir_path, uuid::Uuid::new_v4());
let unique_build_dir = format!("{}/{}", unique_cache_dir, "build");
let unique_installed_db = format!("{}/{}", unique_cache_dir, "pkgdb");
let cfg: Config = Config {
repo: Repo {
repo_url: format!(r"http://mesk.anthrill.i2p/repo/{}", std::env::consts::ARCH),
repo_http_url: format!(r"http://mesk.anthrill.com/repo/{}", std::env::consts::ARCH)
.into(),
auto_update: true,
destination: (String::from("mesk"), String::from("mesk")),
i2p_http_proxy_port: 4444,
},
log: Log {
log_file: String::from("mesk.log"),
log_level: Loglevel::Info,
},
paths: Paths {
cache_dir: String::from(&unique_cache_dir),
build_dir: String::from(&unique_build_dir),
installed_db: String::from(&unique_installed_db),
},
};
// Export this config as TOML so runtime code can read it via MESK_CONFIG_TOML
if let Ok(toml_str) = toml::to_string(&cfg) {
unsafe {
std::env::set_var("MESK_CONFIG_TOML", toml_str);
}
}
cfg
}
|