Welcome back to the series. If this is your first time here, I recommend https://ryangjchandler.co.uk/posts/rebuilding-composer-in-rust-setting-up-the-command-line-interface so you don't miss out on cool stuff.
#[cfg(test)] mod tests { use super::Downloader; #[test] fn it_can_download_a_file() { let downloader = Downloader::new().unwrap(); let downloaded_file = downloader.download("https://www.rust-lang.org/logos/rust-logo-512x512.png").unwrap(); assert!(downloaded_file.path.exists()); }}
#[test] fn it_tidies_up_after_itself() { let downloader = Downloader::new().unwrap(); let downloaded_file = downloader.download("https://www.rust-lang.org/logos/rust-logo-512x512.png").unwrap(); assert!(downloaded_file.path.exists()); drop(downloader); assert!(!downloaded_file.path.exists()); } running 2 tests test tests::it_can_download_a_file... ok test tests::it_tidies_up_after_itself... ok test result: ok.
In the next part of the series I'll start implementing the actual package resolving stuff.