Store an Fs on Workspace, pass it to each Worktree

Push test-only worktree behavior down into the Fs,
via a `watch` method which provides fs events.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2021-07-12 17:26:14 -07:00
co-authored by Nathan Sobo
parent 86ca442fbe
commit 2a90347b82
8 changed files with 213 additions and 244 deletions
+5 -3
View File
@@ -2734,7 +2734,7 @@ mod tests {
use crate::{
test::{build_app_state, temp_tree},
util::RandomCharIter,
worktree::{Worktree, WorktreeHandle},
worktree::{RealFs, Worktree, WorktreeHandle},
};
use gpui::ModelHandle;
use rand::prelude::*;
@@ -3209,7 +3209,8 @@ mod tests {
"file2": "def",
"file3": "ghi",
}));
let tree = cx.add_model(|cx| Worktree::local(dir.path(), Default::default(), cx));
let tree = cx
.add_model(|cx| Worktree::local(dir.path(), Default::default(), Arc::new(RealFs), cx));
tree.flush_fs_events(&cx).await;
cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
.await;
@@ -3321,7 +3322,8 @@ mod tests {
async fn test_file_changes_on_disk(mut cx: gpui::TestAppContext) {
let initial_contents = "aaa\nbbbbb\nc\n";
let dir = temp_tree(json!({ "the-file": initial_contents }));
let tree = cx.add_model(|cx| Worktree::local(dir.path(), Default::default(), cx));
let tree = cx
.add_model(|cx| Worktree::local(dir.path(), Default::default(), Arc::new(RealFs), cx));
cx.read(|cx| tree.read(cx).as_local().unwrap().scan_complete())
.await;