From 540aa1748a7abc2b7a0e69f6712c3c0cbd07cc8e Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 8 Jul 2022 12:16:42 +0200 Subject: [PATCH] Add unit test for ignored files in file finder --- crates/file_finder/src/file_finder.rs | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 67077f24ea..720e0142be 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -412,6 +412,51 @@ mod tests { }); } + #[gpui::test] + async fn test_ignored_files(cx: &mut gpui::TestAppContext) { + let app_state = cx.update(AppState::test); + app_state + .fs + .as_fake() + .insert_tree( + "/ancestor", + json!({ + ".gitignore": "ignored-root", + "ignored-root": { + "happiness": "", + "height": "", + "hi": "", + "hiccup": "", + }, + "tracked-root": { + ".gitignore": "height", + "happiness": "", + "height": "", + "hi": "", + "hiccup": "", + }, + }), + ) + .await; + + let project = Project::test( + app_state.fs.clone(), + [ + "/ancestor/tracked-root".as_ref(), + "/ancestor/ignored-root".as_ref(), + ], + cx, + ) + .await; + let (_, workspace) = cx.add_window(|cx| Workspace::new(project, cx)); + let (_, finder) = + cx.add_window(|cx| FileFinder::new(workspace.read(cx).project().clone(), cx)); + finder + .update(cx, |f, cx| f.spawn_search("hi".into(), cx)) + .await; + finder.read_with(cx, |f, _| assert_eq!(f.matches.len(), 7)); + } + #[gpui::test] async fn test_single_file_worktrees(cx: &mut gpui::TestAppContext) { let app_state = cx.update(AppState::test);