Skip to content

Commit a265e11

Browse files
committed
More tests for zipper module
1 parent 5d8943a commit a265e11

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

encryptify-lib/tests/zipper.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,37 @@ fn test_zip_folder_creates_zip_archive() {
2525
fs::remove_dir_all(folder_path).unwrap();
2626
fs::remove_file(output_path).unwrap();
2727
}
28+
29+
#[test]
30+
fn test_zip_folder_multiple_files() {
31+
// Arrange: Set up a test folder with multiple files
32+
let folder_path = "multi_file_test_folder";
33+
let output_path = "multi_file_test_folder.zip";
34+
fs::create_dir_all(folder_path).unwrap();
35+
std::fs::write(format!("{}/file1.txt", folder_path), b"File 1").unwrap();
36+
std::fs::write(format!("{}/file2.txt", folder_path), b"File 2").unwrap();
37+
38+
// Act: Zip the folder
39+
zip_folder(folder_path, output_path);
40+
41+
// Assert: Check if the output zip file exists
42+
assert!(Path::new(output_path).exists());
43+
44+
// Cleanup
45+
fs::remove_file(output_path).unwrap();
46+
fs::remove_dir_all(folder_path).unwrap();
47+
}
48+
49+
#[test]
50+
fn test_zip_folder_handles_empty_folder() {
51+
let folder_path = "empty_test_folder";
52+
let output_path = "empty_test_folder.zip";
53+
fs::create_dir_all(folder_path).unwrap();
54+
55+
zip_folder(folder_path, output_path);
56+
57+
assert!(Path::new(output_path).exists());
58+
59+
fs::remove_file(output_path).unwrap();
60+
fs::remove_dir_all(folder_path).unwrap();
61+
}

0 commit comments

Comments
 (0)