Skip to content

Commit

Permalink
tests update
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodesdev committed Jun 6, 2024
1 parent c73c934 commit f940865
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/cli/src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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::<Vec<_>>();

futures::future::join_all(handles).await;
}
}

Expand Down

0 comments on commit f940865

Please sign in to comment.