From e5cd81bdd1ab7867c240b7a91f30414f604b0318 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Fri, 26 Jan 2024 15:14:49 +0000 Subject: [PATCH] refactor: [#647] E2E tests. Extract function --- src/e2e/runner.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/e2e/runner.rs b/src/e2e/runner.rs index 23b534ee4..818210886 100644 --- a/src/e2e/runner.rs +++ b/src/e2e/runner.rs @@ -63,16 +63,13 @@ pub fn run() { assert_there_is_at_least_one_service_per_type(&running_services); - let tracker_checker_config = - serde_json::to_string_pretty(&running_services).expect("Running services should be serialized into JSON"); - let temp_dir = create_temp_dir(); - let mut tracker_checker_config_path = PathBuf::from(&temp_dir.temp_dir.path()); - tracker_checker_config_path.push(TRACKER_CHECKER_CONFIG_FILE); - - write_tracker_checker_config_file(&tracker_checker_config_path, &tracker_checker_config); + let tracker_checker_config_path = + create_tracker_checker_config_file(&running_services, temp_dir.temp_dir.path(), TRACKER_CHECKER_CONFIG_FILE); + // todo: inject the configuration with an env variable so that we don't have + // to create the temporary directory/file. run_tracker_checker(&tracker_checker_config_path).expect("All tracker services should be running correctly"); // More E2E tests could be added here in the future. @@ -159,6 +156,18 @@ fn assert_there_is_at_least_one_service_per_type(running_services: &RunningServi ); } +fn create_tracker_checker_config_file(running_services: &RunningServices, config_path: &Path, config_name: &str) -> PathBuf { + let tracker_checker_config = + serde_json::to_string_pretty(&running_services).expect("Running services should be serialized into JSON"); + + let mut tracker_checker_config_path = PathBuf::from(&config_path); + tracker_checker_config_path.push(config_name); + + write_tracker_checker_config_file(&tracker_checker_config_path, &tracker_checker_config); + + tracker_checker_config_path +} + fn write_tracker_checker_config_file(config_file_path: &Path, config: &str) { info!( "Writing Tracker Checker configuration file: {:?} \n{config}",