fn reqwest_downloader_does_not_leave_file_on_failure() {
        let url = Url::parse(&mockito::server_url()).expect("could not parse url");
        let url = url.join("bad_file.zip").expect("could not create url");

        let mock_endpoint = mock("GET", "/bad_file.zip").with_status(503).create();

        let tmp_dir = TempDir::new("example").expect("could not create tempdir");
        let file_path = tmp_dir.path().join("some_file_location.txt");

        assert!(!file_path.exists());

        let result = download(&url, &file_path.as_os_str().to_string_lossy());

        assert_eq!(
            format!("{:?}", result),
            format!(
                "Err(ActionError(\"During http GET request to {url}: \
                received server error 503\"))"
            )
        );
        assert!(!file_path.exists());
        mock_endpoint.assert();
    }
// Test that ReqwestDownloader downloads from the given url to the given file
Test that ReqwestDownloader downloads from the given url to the given file
Test that ReqwestDownloader downloads from the given url to the given file
fn reqwest_downloader_does_not_leave_file_on_failure() {
        let url = Url::parse(&mockito::server_url()).expect("could not parse url");
        let url = url.join("bad_file.zip").expect("could not create url");
        let mock_endpoint = mock("GET", "/bad_file.zip").with_status(503).create();
        let tmp_dir = TempDir::new("example").expect("could not create tempdir");
        let file_path = tmp_dir.path().join("some_file_location.txt");
        assert!(!file_path.exists());
        let result = download(&url, &file_path.as_os_str().to_string_lossy());
        assert_eq!(
            format!("{:?}", result),
            format!(
                "Err(ActionError(\"During http GET request to {url}: \
                received server error 503\"))"
            )
        );
        assert!(!file_path.exists());
        mock_endpoint.assert();
    }
fn reqwest_downloader_does_not_leave_file_on_failure ( ) { let url = Url :: parse ( & mockito :: server_url ( ) ) . expect ( " " ) ; let url = url . join ( " " ) . expect ( " " ) ; let mock_endpoint = mock ( " " , " " ) . with_status ( 503 ) . create ( ) ; let tmp_dir = TempDir :: new ( " " ) . expect ( " " ) ; let file_path = tmp_dir . path ( ) . join ( " " ) ; assert ! ( file_path exists ( ) ) ; let result = download ( & url , & file_path . as_os_str ( ) . to_string_lossy ( ) ) ; assert_eq ! ( format ( " " result ) format ( " \" \
 \" " ) ) ; assert ! ( file_path exists ( ) ) ; mock_endpoint . assert ( ) ; }
Test that ReqwestDownloader downloads from the given url to the given file
Test that ReqwestDownloader downloads from the given url to the given file