From f5fe6b157f8b653d2eeee2cba59dd5881391ee2a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 27 Sep 2022 17:35:55 +0200 Subject: [PATCH] Make assist tests panic again on empty source changes --- crates/ide-assists/src/tests.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs index 258144bae3d..a3bb66e379e 100644 --- a/crates/ide-assists/src/tests.rs +++ b/crates/ide-assists/src/tests.rs @@ -96,8 +96,10 @@ fn check_doc_test(assist_id: &str, before: &str, after: &str) { }); let actual = { - let source_change = - assist.source_change.expect("Assist did not contain any source changes"); + let source_change = assist + .source_change + .filter(|it| !it.source_file_edits.is_empty() || !it.file_system_edits.is_empty()) + .expect("Assist did not contain any source changes"); let mut actual = before; if let Some(source_file_edit) = source_change.get_source_edit(file_id) { source_file_edit.apply(&mut actual); @@ -140,8 +142,10 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult<'_>, assist_la match (assist, expected) { (Some(assist), ExpectedResult::After(after)) => { - let source_change = - assist.source_change.expect("Assist did not contain any source changes"); + let source_change = assist + .source_change + .filter(|it| !it.source_file_edits.is_empty() || !it.file_system_edits.is_empty()) + .expect("Assist did not contain any source changes"); let skip_header = source_change.source_file_edits.len() == 1 && source_change.file_system_edits.len() == 0;