Skip to content

Commit e5cd81b

Browse files
committed
refactor: [#647] E2E tests. Extract function
1 parent 68f71be commit e5cd81b

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/e2e/runner.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,13 @@ pub fn run() {
6363

6464
assert_there_is_at_least_one_service_per_type(&running_services);
6565

66-
let tracker_checker_config =
67-
serde_json::to_string_pretty(&running_services).expect("Running services should be serialized into JSON");
68-
6966
let temp_dir = create_temp_dir();
7067

71-
let mut tracker_checker_config_path = PathBuf::from(&temp_dir.temp_dir.path());
72-
tracker_checker_config_path.push(TRACKER_CHECKER_CONFIG_FILE);
73-
74-
write_tracker_checker_config_file(&tracker_checker_config_path, &tracker_checker_config);
68+
let tracker_checker_config_path =
69+
create_tracker_checker_config_file(&running_services, temp_dir.temp_dir.path(), TRACKER_CHECKER_CONFIG_FILE);
7570

71+
// todo: inject the configuration with an env variable so that we don't have
72+
// to create the temporary directory/file.
7673
run_tracker_checker(&tracker_checker_config_path).expect("All tracker services should be running correctly");
7774

7875
// 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
159156
);
160157
}
161158

159+
fn create_tracker_checker_config_file(running_services: &RunningServices, config_path: &Path, config_name: &str) -> PathBuf {
160+
let tracker_checker_config =
161+
serde_json::to_string_pretty(&running_services).expect("Running services should be serialized into JSON");
162+
163+
let mut tracker_checker_config_path = PathBuf::from(&config_path);
164+
tracker_checker_config_path.push(config_name);
165+
166+
write_tracker_checker_config_file(&tracker_checker_config_path, &tracker_checker_config);
167+
168+
tracker_checker_config_path
169+
}
170+
162171
fn write_tracker_checker_config_file(config_file_path: &Path, config: &str) {
163172
info!(
164173
"Writing Tracker Checker configuration file: {:?} \n{config}",

0 commit comments

Comments
 (0)