8559: Add some more error messages to fixture failure cases r=Veykril a=Veykril

Follow up for #8557
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-04-17 19:37:59 +00:00 committed by GitHub
commit 19fc1f333f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -35,7 +35,7 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static {
fn with_position(ra_fixture: &str) -> (Self, FilePosition) {
let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture);
let offset = match range_or_offset {
RangeOrOffset::Range(_) => panic!(),
RangeOrOffset::Range(_) => panic!("Expected a cursor position, got a range instead"),
RangeOrOffset::Offset(it) => it,
};
(db, FilePosition { file_id, offset })
@ -45,7 +45,7 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static {
let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture);
let range = match range_or_offset {
RangeOrOffset::Range(it) => it,
RangeOrOffset::Offset(_) => panic!(),
RangeOrOffset::Offset(_) => panic!("Expected a cursor range, got a position instead"),
};
(db, FileRange { file_id, range })
}

View File

@ -84,7 +84,8 @@ fn check_doc_test(assist_id: &str, before: &str, after: &str) {
});
let actual = {
let source_change = assist.source_change.unwrap();
let source_change =
assist.source_change.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);
@ -121,7 +122,8 @@ fn check(handler: Handler, before: &str, expected: ExpectedResult, assist_label:
match (assist, expected) {
(Some(assist), ExpectedResult::After(after)) => {
let source_change = assist.source_change.unwrap();
let source_change =
assist.source_change.expect("Assist did not contain any source changes");
assert!(!source_change.source_file_edits.is_empty());
let skip_header = source_change.source_file_edits.len() == 1
&& source_change.file_system_edits.len() == 0;