Add a failing test for detecting a file move
This commit is contained in:
@@ -2,6 +2,7 @@ use rand::Rng;
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
path::{Path, PathBuf},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tempdir::TempDir;
|
||||
|
||||
@@ -136,3 +137,18 @@ fn write_tree(path: &Path, tree: serde_json::Value) {
|
||||
panic!("You must pass a JSON object to this helper")
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn assert_condition(poll_interval: u64, timeout: u64, mut f: impl FnMut() -> bool) {
|
||||
let poll_interval = Duration::from_millis(poll_interval);
|
||||
let timeout = Duration::from_millis(timeout);
|
||||
let start = Instant::now();
|
||||
loop {
|
||||
if f() {
|
||||
return;
|
||||
} else if Instant::now().duration_since(start) < timeout {
|
||||
smol::Timer::after(poll_interval).await;
|
||||
} else {
|
||||
panic!("timed out waiting on condition");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user