Skip to content

Commit

Permalink
fixed windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
czarte committed Dec 8, 2023
1 parent 08930b9 commit 15e66e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions masq_lib/src/multi_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ impl Display for ConfigFileVclError {
match self {
ConfigFileVclError::OpenError(path, _) => write!(
fmt,
"Couldn't open configuration file {:?}. Are you sure it exists?",
path
"Couldn't open configuration file \"{}\". Are you sure it exists?",
path.to_string_lossy()
),
ConfigFileVclError::CorruptUtf8(path) => write!(
fmt,
Expand Down
17 changes: 12 additions & 5 deletions node/src/node_configurator/node_configurator_standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,9 @@ mod tests {

let result =
server_initializer_collected_params(&dir_wrapper, args_vec.as_slice()).unwrap_err();
let expected = ConfiguratorError::new(vec![ ParamError::new("config-file", "Couldn't open configuration file \"generated/test/node_configurator_standard/server_initializer_collected_params_handles_only_path_in_config_file_param/home/generated/test/node_configurator_standard/server_initializer_collected_params_handles_only_path_in_config_file_param/home\". Are you sure it exists?")]);

let result_path = format!("Couldn't open configuration file \"{}\". Are you sure it exists?", home_dir.as_path().join(home_dir.as_path()).to_str().unwrap());
let expected = ConfiguratorError::new(vec![ ParamError::new("config-file", result_path.as_str())]);

assert_eq!(result, expected);
}
Expand Down Expand Up @@ -994,7 +996,7 @@ mod tests {
#[cfg(target_os = "windows")]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"generated/test/node_configurator_standard/server_initializer_collected_params_rewrite_config_files_parameters_from_command_line/home\\data_dir\\MASQ\\polygon-mainnet".to_string()
"/home/booga\\data_dir\\MASQ\\polygon-mainnet".to_string()
);
}

Expand Down Expand Up @@ -1052,7 +1054,7 @@ mod tests {
#[cfg(target_os = "windows")]
assert_eq!(
value_m!(env_multiconfig, "data-directory", String).unwrap(),
"generated/test/node_configurator_standard/server_initializer_collected_params_rewrite_config_files_parameters_from_environment/home\\data_dir\\MASQ\\polygon-mainnet".to_string()
"/home/booga\\data_dir\\MASQ\\polygon-mainnet".to_string()
);
}

Expand Down Expand Up @@ -1084,8 +1086,8 @@ mod tests {
#[cfg(target_os = "windows")]
let args = ArgsBuilder::new()
.param("--blockchain-service-url", "https://www.mainnet1.com")
.param("--config-file", "~/masqhome\\config.toml")
.param("--data-directory", "~/masqhome");
.param("--config-file", "~\\masqhome\\config.toml")
.param("--data-directory", "~\\masqhome");
let args_vec: Vec<String> = args.into();
let dir_wrapper = DirsWrapperMock::new()
.home_dir_result(Some(home_dir.to_path_buf()))
Expand Down Expand Up @@ -1249,9 +1251,14 @@ mod tests {
running_test();
let home_dir = PathBuf::from("/unexisting_home/unexisting_alice");
let data_dir = home_dir.join("data_dir");
#[cfg(not(target_os = "windows"))]
let args = ArgsBuilder::new()
.param("--config-file", "/home/booga/booga.toml") // nonexistent config file: should return error because user-specified
.param("--chain", "polygon-mainnet");
#[cfg(target_os = "windows")]
let args = ArgsBuilder::new()
.param("--config-file", "C:\\home\\booga\\booga.toml") // nonexistent config file: should return error because user-specified
.param("--chain", "polygon-mainnet");
let args_vec: Vec<String> = args.into();
let dir_wrapper = DirsWrapperMock::new()
.home_dir_result(Some(home_dir))
Expand Down

0 comments on commit 15e66e6

Please sign in to comment.