Use fake file system for buffer identity test

Antonio Scandurra created

Change summary

crates/project/src/project_tests.rs | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)

Detailed changes

crates/project/src/project_tests.rs 🔗

@@ -2261,14 +2261,22 @@ async fn test_rescan_and_remote_updates(
 }
 
 #[gpui::test(iterations = 10)]
-async fn test_buffer_identity_across_renames(cx: &mut gpui::TestAppContext) {
-    let dir = temp_tree(json!({
-        "a": {
-            "file1": "",
-        }
-    }));
+async fn test_buffer_identity_across_renames(
+    deterministic: Arc<Deterministic>,
+    cx: &mut gpui::TestAppContext,
+) {
+    let fs = FakeFs::new(cx.background());
+    fs.insert_tree(
+        "/dir",
+        json!({
+            "a": {
+                "file1": "",
+            }
+        }),
+    )
+    .await;
 
-    let project = Project::test(Arc::new(RealFs), [dir.path()], cx).await;
+    let project = Project::test(fs, [Path::new("/dir")], cx).await;
     let tree = project.read_with(cx, |project, cx| project.worktrees(cx).next().unwrap());
     let tree_id = tree.read_with(cx, |tree, _| tree.id());
 
@@ -2297,7 +2305,7 @@ async fn test_buffer_identity_across_renames(cx: &mut gpui::TestAppContext) {
         .unwrap()
         .await
         .unwrap();
-    tree.flush_fs_events(cx).await;
+    deterministic.run_until_parked();
     assert_eq!(id_for_path("b", cx), dir_id);
     assert_eq!(id_for_path("b/file1", cx), file_id);
     buffer.read_with(cx, |buffer, _| assert!(!buffer.is_dirty()));