zip-rs-wasm/tests/extract.rs
Zac Pullar-Strecker c074a3090c run rustfmt
2020-06-16 14:45:36 +12:00

22 lines
571 B
Rust

extern crate zip;
use std::fs;
use std::io;
use std::path::PathBuf;
use zip::ZipArchive;
// This tests extracting the contents of a zip file
#[test]
fn extract() {
let mut v = Vec::new();
v.extend_from_slice(include_bytes!("../tests/data/files_and_dirs.zip"));
let mut archive = ZipArchive::new(io::Cursor::new(v)).expect("couldn't open test zip file");
archive
.extract(&PathBuf::from("test_directory"))
.expect("extract failed");
// Cleanup
fs::remove_dir_all("test_directory").expect("failed to remove extracted files");
}