Add simple test

This commit is contained in:
Marcel Müller 2016-07-22 13:54:13 +02:00
parent 74dcd1f141
commit 1c71326ede
No known key found for this signature in database
GPG key ID: 84BD3634786D56CF

View file

@ -137,47 +137,19 @@ mod fs {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
// use super::LazyFile; use super::LazyFile;
// use std::io::{Read, Write}; use std::io::Read;
// use std::path::PathBuf; use std::path::PathBuf;
// use tempdir::TempDir;
#[test]
fn lazy_file() {
let mut path = PathBuf::from("/tests");
path.set_file_name("test1");
let mut lf = LazyFile::Absent(path);
lf.write_file_content(b"Hello World").unwrap();
let mut bah = Vec::new();
lf.get_file_content().unwrap().read_to_end(&mut bah).unwrap();
assert_eq!(bah, b"Hello World");
}
// fn get_dir() -> TempDir {
// TempDir::new("test-image").unwrap()
// }
// #[test]
// fn lazy_file() {
// let dir = get_dir();
// let mut path = PathBuf::from(dir.path());
// path.set_file_name("test1");
// let mut lf = LazyFile::Absent(path);
// write!(lf.create_file().unwrap(), "Hello World").unwrap();
// dir.close().unwrap();
// }
// #[test]
// fn lazy_file_with_file() {
// let dir = get_dir();
// let mut path = PathBuf::from(dir.path());
// path.set_file_name("test2");
// let mut lf = LazyFile::Absent(path.clone());
// {
// let mut file = lf.create_file().unwrap();
// file.write(b"Hello World").unwrap();
// file.sync_all().unwrap();
// }
// {
// let mut file = lf.get_file_mut().unwrap();
// let mut s = Vec::new();
// file.read_to_end(&mut s).unwrap();
// assert_eq!(s, "Hello World".to_string().into_bytes());
// }
// dir.close().unwrap();
// }
} }