Skip to content

Commit

Permalink
fixing tests for windows os
Browse files Browse the repository at this point in the history
  • Loading branch information
czarte committed Oct 30, 2023
1 parent 18d0cc1 commit efd3fbb
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions node/src/node_configurator/node_configurator_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,15 @@ pub fn server_initializer_collected_params<'a>(
user_specific_data.data_directory.to_string_lossy().as_ref(),
user_specific_data.data_directory_spec,
);
#[cfg(not(target_os = "windows"))]
fill_specified_or_unspecified_box("--real-user", cf_real_user.as_str(), cf_real_user_specified);
#[cfg(not(target_os = "windows"))]
fill_specified_or_unspecified_box(
"--real-user",
env_real_user.as_str(),
env_real_user_specified,
);
#[cfg(not(target_os = "windows"))]
fill_specified_or_unspecified_box(
"--real-user",
cmd_real_user.as_str(),
Expand Down Expand Up @@ -885,10 +888,17 @@ mod tests {
let result = server_initializer_collected_params(&dir_wrapper, args_vec.as_slice());
let env_multiconfig = result.unwrap();

#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"booga/data_dir/MASQ/polygon-mainnet".to_string()
);
#[cfg(target_os = "windows")]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"generated/test/node_configurator_standard/multi_config_vcl_is_computed_do_right_job/home\\data_dir\\MASQ\\polygon-mainnet".to_string()
);
#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(env_multiconfig, "config-file", String).unwrap(),
current_dir().expect("expected curerrnt dir")
Expand Down Expand Up @@ -926,10 +936,17 @@ mod tests {
let env_multiconfig = result.unwrap();

assert_eq!(env_multiconfig.is_user_specified("--data-directory"), false);
#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"booga/data_dir/MASQ/polygon-mainnet".to_string()
);
#[cfg(target_os = "windows")]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"generated/test/node_configurator_standard/multi_config_vcl_is_computed_do_right_job/home\\data_dir\\MASQ\\polygon-mainnet".to_string()
);
#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(env_multiconfig, "config-file", String).unwrap(),
current_dir().unwrap().join(PathBuf::from( "./generated/test/node_configurator_standard/server_initializer_collected_params_handle_config_file_from_environment_and_real_user_from_config_file_with_path_started_by_dot/config.toml")).to_string_lossy().to_string()
Expand Down Expand Up @@ -995,6 +1012,7 @@ mod tests {
vec![
("MASQ_CONFIG_FILE", "config/config.toml"),
("MASQ_DATA_DIRECTORY", "/unexistent/directory"),
#[cfg(not(target_os = "windows"))]
("MASQ_REAL_USER", "999:999:/home/malooga"),
]
.into_iter()
Expand All @@ -1015,6 +1033,7 @@ mod tests {
&value_m!(multiconfig, "data-directory", String).unwrap(),
&home_dir.to_string_lossy().to_string()
);
#[cfg(not(target_os = "windows"))]
assert_eq!(
&value_m!(multiconfig, "real-user", String).unwrap(),
"1001:1001:cooga"
Expand Down Expand Up @@ -1078,15 +1097,20 @@ mod tests {
let params = server_initializer_collected_params(&dir_wrapper, args_vec.as_slice());
let result = params.as_ref().expect("REASON");
let multiconfig = result;

#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(multiconfig, "config-file", String).unwrap(),
current_directory.join("generated/test/node_configurator_standard/server_initializer_collected_params_combine_vlcs_properly/home/config.toml").to_string_lossy().to_string()
);
#[cfg(target_os = "windows")]
assert_eq!(
value_m!(multiconfig, "config-file", String).unwrap(),
current_directory.join("generated/test/node_configurator_standard/server_initializer_collected_params_combine_vlcs_properly/home\\config.toml").to_string_lossy().to_string()
);
assert_eq!(multiconfig.is_user_specified("--data-directory"), true);

#[cfg(not(target_os = "windows"))]
assert_eq!(multiconfig.is_user_specified("--real-user"), true);
#[cfg(not(target_os = "windows"))]
assert_eq!(
value_m!(multiconfig, "real-user", String).unwrap(),
"1001:1001:cooga".to_string()
Expand Down

0 comments on commit efd3fbb

Please sign in to comment.