diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index ccae9db92b..af1af933c5 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -7,8 +7,9 @@ use unindent::Unindent; use super::*; use crate::test::{ - assert_text_with_selections, build_editor, editor_lsp_test_context::EditorLspTestContext, - editor_test_context::EditorTestContext, select_ranges, + assert_text_with_selections, build_editor, editor_git_test_context::EditorGitTestContext, + editor_lsp_test_context::EditorLspTestContext, editor_test_context::EditorTestContext, + select_ranges, }; use gpui::{ geometry::rect::RectF, @@ -5079,6 +5080,11 @@ fn test_combine_syntax_and_fuzzy_match_highlights() { ); } +#[gpui::test] +fn go_to_hunk(cx: &mut gpui::TestAppContext) { + let mut cx = EditorGitTestContext::new(cx); +} + fn empty_range(row: usize, column: usize) -> Range { let point = DisplayPoint::new(row as u32, column as u32); point..point diff --git a/crates/editor/src/test.rs b/crates/editor/src/test.rs index 48652c44b7..e4146e38bb 100644 --- a/crates/editor/src/test.rs +++ b/crates/editor/src/test.rs @@ -1,3 +1,4 @@ +pub mod editor_git_test_context; pub mod editor_lsp_test_context; pub mod editor_test_context; diff --git a/crates/editor/src/test/editor_git_test_context.rs b/crates/editor/src/test/editor_git_test_context.rs new file mode 100644 index 0000000000..10f0e002aa --- /dev/null +++ b/crates/editor/src/test/editor_git_test_context.rs @@ -0,0 +1,56 @@ +use std::ops::{Deref, DerefMut}; + +use gpui::ModelHandle; +use language::Buffer; +use settings::Settings; + +use crate::MultiBuffer; + +use super::{build_editor, editor_test_context::EditorTestContext}; + +pub struct EditorGitTestContext<'a> { + pub cx: EditorTestContext<'a>, + pub buffer: ModelHandle, +} + +impl<'a> EditorGitTestContext<'a> { + pub async fn new(cx: &'a mut gpui::TestAppContext) -> EditorGitTestContext<'a> { + let (window_id, buffer, editor) = cx.update(|cx| { + cx.set_global(Settings::test(cx)); + crate::init(cx); + + let buffer = cx.add_model(|cx| Buffer::new(0, "", cx)); + let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx)); + + let (window_id, editor) = + cx.add_window(Default::default(), |cx| build_editor(multibuffer, cx)); + + editor.update(cx, |_, cx| cx.focus_self()); + + (window_id, buffer, editor) + }); + + Self { + cx: EditorTestContext { + cx, + window_id, + editor, + }, + buffer, + } + } +} + +impl<'a> Deref for EditorGitTestContext<'a> { + type Target = EditorTestContext<'a>; + + fn deref(&self) -> &Self::Target { + &self.cx + } +} + +impl<'a> DerefMut for EditorGitTestContext<'a> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.cx + } +} diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 9f0ebe32f7..db8fb8e3ff 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -3257,7 +3257,6 @@ mod tests { } }, "c.txt": "", - })); let http_client = FakeHttpClient::with_404_response();