From f94086561e7e3f4b6bccc6c5d7f35ae9b91217a8 Mon Sep 17 00:00:00 2001 From: dcodesdev <101001810+dcodesdev@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:09:27 +0300 Subject: [PATCH] tests update --- crates/cli/src/download.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/cli/src/download.rs b/crates/cli/src/download.rs index 88512a3..3f693a3 100644 --- a/crates/cli/src/download.rs +++ b/crates/cli/src/download.rs @@ -98,8 +98,8 @@ mod tests { fs::create_dir_all("temp/test_downloads_challenge").ok(); env::set_current_dir("temp/test_downloads_challenge").ok(); - for challenge in CHALLENGES { - get_challenge(challenge) + let test_challenge = |challenge: String| async move { + get_challenge(&challenge) .await .expect("Failed to download challenge"); @@ -111,15 +111,21 @@ mod tests { ]; for file in paths_to_exist.iter() { - let path = format!("{}/{}", challenge, file); - - assert!(Path::new(&path).exists()); + let path = Path::new(&challenge).join(file); + assert!(path.exists(), "File does not exist: {:?}", path); // all files shouldn't have the content "404: Not Found" let contents = fs::read_to_string(&path).unwrap(); assert!(!contents.contains("404: Not Found")); } - } + }; + + let handles = CHALLENGES + .iter() + .map(|c| tokio::spawn(test_challenge(c.to_string()))) + .collect::>(); + + futures::future::join_all(handles).await; } }