extern crate tempfile;
use std::io::prelude::*;
#[test]
fn test_tempdir() {
let tmp_dir = tempfile::Builder::new()
.prefix(env!("CARGO_PKG_NAME"))
.rand_bytes(5)
.tempdir()
.expect("not possible to create tempfile");
let path_dir = tmp_dir.path().to_owned();
let path_file = tmp_dir.path().join("file.txt");
let mut buffer = std::fs::File::create(&path_file)
.expect(format!("Not possible to open file {:?}", &path_file).as_str());
buffer.write_all(b"hello")
.expect(format!("Not possible to write 'hello' to file: {:?}", &path_file).as_str());
drop(buffer);
drop(tmp_dir);
assert!(!path_file.exists());
assert!(!path_dir.exists());
}