Test opening for append and creating another copy

This commit is contained in:
Chris Hennick 2023-05-04 16:22:19 -07:00
parent 08ec7ca710
commit b1ac3912db
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -1582,6 +1582,8 @@ mod test {
const RT_TEST_FILENAME: &str = "subfolder/sub-subfolder/can't_stop.txt";
#[cfg(test)]
const SECOND_FILENAME: &str = "different_name.xyz";
#[cfg(test)]
const THIRD_FILENAME: &str = "third_name.xyz";
#[test]
fn test_shallow_copy() {
@ -1640,10 +1642,13 @@ mod test {
.deep_copy_file(RT_TEST_FILENAME, SECOND_FILENAME)
.unwrap();
let zip = writer.finish().unwrap();
let mut writer = ZipWriter::new_append(zip).unwrap();
writer.deep_copy_file(RT_TEST_FILENAME, THIRD_FILENAME).unwrap();
let zip = writer.finish().unwrap();
let mut reader = ZipArchive::new(zip).unwrap();
let mut file_names: Vec<&str> = reader.file_names().collect();
file_names.sort();
let mut expected_file_names = vec![RT_TEST_FILENAME, SECOND_FILENAME];
let mut expected_file_names = vec![RT_TEST_FILENAME, SECOND_FILENAME, THIRD_FILENAME];
expected_file_names.sort();
assert_eq!(file_names, expected_file_names);
let mut first_file_content = String::new();