-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-783 Fix tests failing on non standard environment #432
Changes from all commits
3f8beab
f9ec951
acbbb0e
a6ab82e
f5fab1d
ab83b30
ce8a7cc
c3566a6
0806467
35733e0
bd1b844
b04a550
e709bb0
79a2ce0
752407d
e341de1
94ea1b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -376,7 +376,6 @@ mod tests { | |
make_pre_populated_mocked_directory_wrapper, make_simplified_multi_config, | ||
}; | ||
use crate::test_utils::{assert_string_contains, main_cryptde, ArgsBuilder}; | ||
use dirs::home_dir; | ||
use masq_lib::blockchains::chains::Chain; | ||
use masq_lib::constants::DEFAULT_CHAIN; | ||
use masq_lib::multi_config::VirtualCommandLine; | ||
|
@@ -1075,14 +1074,16 @@ mod tests { | |
} | ||
|
||
#[test] | ||
fn server_initializer_collected_params_handle_tilde_in_path_config_file_from_commandline_and_real_user_from_config_file( | ||
) { | ||
fn tilde_in_config_file_path_from_commandline_and_args_uploaded_from_config_file() { | ||
running_test(); | ||
let _guard = EnvironmentGuard::new(); | ||
let _clap_guard = ClapGuard::new(); | ||
let home_dir = home_dir().expect("expectexd home dir"); | ||
let data_dir = &home_dir.join("masqhome"); | ||
let _create_data_dir = create_dir_all(data_dir); | ||
let home_dir = ensure_node_home_directory_exists( | ||
"node_configurator_standard", | ||
"tilde_in_config_file_path_from_commandline_and_args_uploaded_from_config_file", | ||
); | ||
let data_dir = home_dir.join("masqhome"); | ||
let _dir = create_dir_all(&data_dir); | ||
let config_file_relative = File::create(data_dir.join("config.toml")).unwrap(); | ||
fill_up_config_file(config_file_relative); | ||
let env_vec_array = vec![ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot write it lower than here but I continue to think that the DirsWrapperMock doesn't belong in here, it should only be the real one. The code should figure out home_dir and data_dir on its own, genuinely. It would be possible that the test wouldn't pass for that reason of what the tests claims but just because you determined it by these supplied values in the Mock. If I'm wrong and the test fails then... I'd be disappointed... but I think we'll have to think that out even further. |
||
|
@@ -1105,16 +1106,30 @@ mod tests { | |
.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())) | ||
.data_dir_result(Some(data_dir.to_path_buf())); | ||
let dir_wrapper = DirsWrapperMock { | ||
data_dir_result: Some(PathBuf::from(current_dir().unwrap().join(&data_dir))), | ||
home_dir_result: Some(PathBuf::from(current_dir().unwrap().join(&home_dir))), | ||
}; | ||
|
||
let result = server_initializer_collected_params(&dir_wrapper, args_vec.as_slice()); | ||
let multiconfig = result.unwrap(); | ||
|
||
assert_eq!( | ||
value_m!(multiconfig, "data-directory", String).unwrap(), | ||
data_dir.to_string_lossy().to_string() | ||
current_dir() | ||
.unwrap() | ||
.join(&data_dir) | ||
.to_string_lossy() | ||
.to_string() | ||
); | ||
assert_eq!( | ||
value_m!(multiconfig, "config-file", String).unwrap(), | ||
current_dir() | ||
.unwrap() | ||
.join(data_dir) | ||
.join(PathBuf::from("config.toml")) | ||
.to_string_lossy() | ||
.to_string() | ||
); | ||
#[cfg(not(target_os = "windows"))] | ||
{ | ||
|
@@ -1123,13 +1138,6 @@ mod tests { | |
"9999:9999:booga" | ||
); | ||
} | ||
assert_eq!( | ||
value_m!(multiconfig, "config-file", String).unwrap(), | ||
data_dir | ||
.join(PathBuf::from("config.toml")) | ||
.to_string_lossy() | ||
.to_string() | ||
); | ||
assert_eq!( | ||
value_m!(multiconfig, "blockchain-service-url", String).unwrap(), | ||
"https://www.mainnet1.com" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned it at the other test already, please try eliminating the
DirsWrapperMock
.