in proxy_agent/src/common/config.rs [195:265]
fn config_struct_test() {
let mut temp_test_path: PathBuf = env::temp_dir();
temp_test_path.push("config_struct_test");
_ = fs::remove_dir_all(&temp_test_path);
match misc_helpers::try_create_folder(&temp_test_path) {
Ok(_) => {}
Err(err) => panic!("Failed to create folder: {}", err),
}
let config_file_path = temp_test_path.join("test_config.json");
let config = create_config_file(config_file_path);
assert_eq!(
r#"C:\logFolderName"#.to_string(),
config.get_log_folder(),
"Log Folder mismatch"
);
assert_eq!(
r#"C:\eventFolderName"#.to_string(),
config.get_event_folder(),
"Event Folder mismatch"
);
assert_eq!(
r#"C:\latchKeyFolderName"#.to_string(),
config.get_latch_key_folder(),
"Latch Key Folder mismatch"
);
assert_eq!(
60u64,
config.get_monitor_interval(),
"get_monitor_interval mismatch"
);
assert_eq!(
15u64,
config.get_poll_key_status_interval(),
"get_poll_key_status_interval mismatch"
);
assert_eq!(
1u8,
config.get_host_gaplugin_support(),
"get_host_gaplugin_support mismatch"
);
assert_eq!(
constants::DEFAULT_MAX_EVENT_FILE_COUNT,
config.get_max_event_file_count(),
"get_max_event_file_count mismatch"
);
assert_eq!(
"ebpfProgramName".to_string(),
config.get_ebpf_program_name(),
"get_ebpf_program_name mismatch"
);
#[cfg(not(windows))]
{
assert_eq!(
PathBuf::from(constants::CGROUP_ROOT),
config.get_cgroup_root(),
"get_cgroup_root mismatch"
);
}
// clean up
_ = fs::remove_dir_all(&temp_test_path);
}