tokio-fs: add tokio_fs::metadata (#433)

This commit is contained in:
Laurențiu Nicola
2018-06-20 13:12:06 -07:00
committed by Carl Lerche
parent b2f77dcebe
commit 04a4bfd455
2 changed files with 53 additions and 1 deletions
+30
View File
@@ -73,3 +73,33 @@ fn read_write() {
})
});
}
#[test]
fn metadata() {
let dir = TempDir::new("tokio-fs-tests").unwrap();
let file_path = dir.path().join("metadata.txt");
let pool = Builder::new().pool_size(1).build();
let (tx, rx) = oneshot::channel();
pool.spawn({
let file_path = file_path.clone();
let file_path2 = file_path.clone();
let file_path3 = file_path.clone();
tokio_fs::metadata(file_path)
.then(|r| {
let _ = r.err().unwrap();
Ok(())
})
.and_then(|_| File::create(file_path2))
.and_then(|_| tokio_fs::metadata(file_path3))
.then(|r| {
assert!(r.unwrap().is_file());
tx.send(())
})
});
rx.wait().unwrap();
}