chore: Cargo fmt
This commit is contained in:
@@ -142,20 +142,20 @@ mod tests {
|
||||
|
||||
TEST_SERVER.get_or_init(|| {
|
||||
let listener = TcpListener::bind(format!("127.0.0.1:{}", TEST_SERVER_PORT)).unwrap();
|
||||
|
||||
|
||||
thread::spawn(move || {
|
||||
for stream in listener.incoming() {
|
||||
thread::spawn(move || {
|
||||
let mut stream = stream.expect("Stream opened correctly");
|
||||
let mut buffer = [0; 1024];
|
||||
let _ = stream.read(&mut buffer);
|
||||
|
||||
|
||||
let response = format!(
|
||||
"HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nContent-Length: {}\r\n\r\n{}",
|
||||
TEST_CONTENT.len(),
|
||||
TEST_CONTENT
|
||||
);
|
||||
|
||||
|
||||
stream.write_all(response.as_bytes()).expect("Can write to stream");
|
||||
stream.flush().expect("Can flush stream");
|
||||
});
|
||||
@@ -203,7 +203,7 @@ mod tests {
|
||||
|
||||
let folder = PathBuf::from(&test.download_path);
|
||||
let result = asset.download_to_path(folder).await.unwrap();
|
||||
|
||||
|
||||
let downloaded_content = std::fs::read_to_string(result).unwrap();
|
||||
assert_eq!(downloaded_content, TEST_CONTENT);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ mod tests {
|
||||
async fn test_download_to_path_already_exists() {
|
||||
let test = setup_test();
|
||||
let folder = PathBuf::from(&test.download_path);
|
||||
|
||||
|
||||
let asset = DownloadableAsset {
|
||||
url: Url::parse(&format!("http://{}/test.txt", test.domain)).unwrap(),
|
||||
file_name: "test.txt".to_string(),
|
||||
@@ -230,14 +230,16 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_download_to_path_failure() {
|
||||
let test = setup_test();
|
||||
|
||||
|
||||
let asset = DownloadableAsset {
|
||||
url: Url::parse("http://127.0.0.1:9999/test.txt").unwrap(),
|
||||
file_name: "test.txt".to_string(),
|
||||
checksum: "some_checksum".to_string(),
|
||||
};
|
||||
|
||||
let result = asset.download_to_path(PathBuf::from(&test.download_path)).await;
|
||||
let result = asset
|
||||
.download_to_path(PathBuf::from(&test.download_path))
|
||||
.await;
|
||||
assert!(result.is_err());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user