conflicts: use insta in conflict tests

This commit is contained in:
Martin von Zweigbergk 2022-07-10 11:01:48 -07:00 committed by Martin von Zweigbergk
parent 9dab88260a
commit fc578a2dd7

View file

@ -16,6 +16,7 @@ use jujutsu_lib::backend::{Conflict, ConflictPart, TreeValue};
use jujutsu_lib::conflicts::{materialize_conflict, parse_conflict, update_conflict_from_content};
use jujutsu_lib::files::MergeHunk;
use jujutsu_lib::repo_path::RepoPath;
use jujutsu_lib::store::Store;
use jujutsu_lib::testutils;
use jujutsu_lib::testutils::TestRepo;
@ -78,11 +79,10 @@ line 5
},
],
};
let mut result: Vec<u8> = vec![];
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
assert_eq!(
String::from_utf8(result).unwrap().as_str(),
"line 1
insta::assert_snapshot!(
&materialize_conflict_string(store, &path, &conflict),
@r###"
line 1
line 2
<<<<<<<
-------
@ -94,7 +94,7 @@ right
>>>>>>>
line 4
line 5
"
"###
);
}
@ -156,11 +156,8 @@ line 5
},
],
};
let mut result: Vec<u8> = vec![];
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
assert_eq!(
String::from_utf8(result).unwrap().as_str(),
"line 1
insta::assert_snapshot!(&materialize_conflict_string(store, &path, &conflict), @r###"
line 1
line 2
<<<<<<<
-------
@ -171,7 +168,7 @@ line 2
>>>>>>>
line 4
line 5
"
"###
);
}
@ -234,11 +231,10 @@ line 5
],
};
let mut result: Vec<u8> = vec![];
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
assert_eq!(
String::from_utf8(result).unwrap().as_str(),
"line 1
insta::assert_snapshot!(
&materialize_conflict_string(store, &path, &conflict),
@r###"
line 1
line 2
<<<<<<<
-------
@ -249,7 +245,7 @@ right
>>>>>>>
line 4
line 5
"
"###
);
}
@ -503,3 +499,9 @@ fn test_update_conflict_from_content() {
}
)
}
fn materialize_conflict_string(store: &Store, path: &RepoPath, conflict: &Conflict) -> String {
let mut result: Vec<u8> = vec![];
materialize_conflict(store, path, conflict, &mut result).unwrap();
String::from_utf8(result).unwrap()
}