use crate::watcher::WorkspaceWatcher;
use crate::workspace::WorkspaceRoot;
pub async fn run_all<W: WorkspaceWatcher>(watcher: &W, root: &WorkspaceRoot) {
watch_yields_a_handle_that_receives_events(watcher, root).await;
changes_are_delivered_to_their_own_root(watcher, root).await;
}
async fn watch_yields_a_handle_that_receives_events<W: WorkspaceWatcher>(
watcher: &W,
root: &WorkspaceRoot,
) {
let mut handle = watcher
.watch(root)
.await
.expect("watch must succeed on a valid root");
let initial = handle.try_recv();
assert!(
initial.is_err(),
"a fresh WatchHandle must not have pre-buffered events"
);
}
async fn changes_are_delivered_to_their_own_root<W: WorkspaceWatcher>(
watcher: &W,
root: &WorkspaceRoot,
) {
let mut first = watcher.watch(root).await.expect("first watch");
let mut second = watcher.watch(root).await.expect("second watch");
let _ = &mut first;
let _ = &mut second;
}