mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-07 00:00:08 +02:00
tokio-fs: add tokio_fs::metadata (#433)
This commit is contained in:
committed by
Carl Lerche
parent
b2f77dcebe
commit
04a4bfd455
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user