in proxy_agent_shared/src/misc_helpers.rs [328:363]
fn json_write_read_from_file_test() {
let mut temp_test_path = env::temp_dir();
temp_test_path.push("json_Write_read_from_file_test");
// clean up and ignore the clean up errors
_ = fs::remove_dir_all(&temp_test_path);
super::try_create_folder(&temp_test_path).unwrap();
let json_file = temp_test_path.as_path();
let json_file = json_file.join("test.json");
let test = TestStruct {
thread_id: super::get_thread_identity(),
date_time_string_with_milliseconds: super::get_date_time_string_with_milliseconds(),
date_time_string: super::get_date_time_string(),
date_time_rfc1123_string: super::get_date_time_rfc1123_string(),
date_time_unix_nano: super::get_date_time_unix_nano(),
long_os_version: super::get_long_os_version(),
current_exe_dir: super::get_current_exe_dir().to_str().unwrap().to_string(),
};
super::json_write_to_file(&test, &json_file).unwrap();
let json = super::json_read_from_file::<TestStruct>(&json_file).unwrap();
assert_eq!(test.thread_id, json.thread_id);
assert_eq!(
test.date_time_string_with_milliseconds,
json.date_time_string_with_milliseconds
);
assert_eq!(test.date_time_string, json.date_time_string);
assert_eq!(test.date_time_rfc1123_string, json.date_time_rfc1123_string);
assert_eq!(test.date_time_unix_nano, json.date_time_unix_nano);
assert_eq!(test.long_os_version, json.long_os_version);
assert_eq!(test.current_exe_dir, json.current_exe_dir);
_ = fs::remove_dir_all(&temp_test_path);
}