Skip to content

Commit 0e37b54

Browse files
Add missing error path test for zip_dir in compress module
Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com>
1 parent 3b2e1b2 commit 0e37b54

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎stdlib/src/compress.rs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,26 @@ pub fn gunzip_archive(archive_path: &str, dst_file: &str) -> std::io::Result<()>
292292
std::io::copy(&mut decoder, &mut output)?;
293293
Ok(())
294294
}
295+
296+
#[cfg(test)]
297+
mod tests {
298+
use super::*;
299+
300+
#[test]
301+
fn test_zip_dir_error_path() {
302+
let temp_dir = std::env::temp_dir().join("techscript_zip_dir_error_test");
303+
std::fs::create_dir_all(&temp_dir).ok();
304+
305+
let dst_file = temp_dir.join("archive.zip");
306+
let non_existent_dir = temp_dir.join("does_not_exist");
307+
308+
let result = zip_dir(
309+
&non_existent_dir.to_string_lossy(),
310+
&dst_file.to_string_lossy(),
311+
);
312+
313+
assert!(result.is_err(), "Expected error when zipping a non-existent directory");
314+
315+
std::fs::remove_dir_all(&temp_dir).ok();
316+
}
317+
}

0 commit comments

Comments
 (0)