tests: levarage the materialize_conflict_string() helper in more places

This commit is contained in:
Martin von Zweigbergk 2023-08-11 13:52:32 -07:00 committed by Martin von Zweigbergk
parent adf9679d4c
commit 94c14d454a

View file

@ -288,10 +288,9 @@ line 5 right
vec![Some(file_value(&base_id))], vec![Some(file_value(&base_id))],
vec![Some(file_value(&left_id)), Some(file_value(&right_id))], vec![Some(file_value(&left_id)), Some(file_value(&right_id))],
); );
let mut result: Vec<u8> = vec![]; let materialized = materialize_conflict_string(store, &path, &conflict);
materialize(&conflict, store, &path, &mut result).unwrap();
insta::assert_snapshot!( insta::assert_snapshot!(
String::from_utf8(result.clone()).unwrap(), materialized,
@r###" @r###"
<<<<<<< <<<<<<<
+++++++ +++++++
@ -317,7 +316,7 @@ line 5 right
// The first add should always be from the left side // The first add should always be from the left side
insta::assert_debug_snapshot!( insta::assert_debug_snapshot!(
parse_conflict(&result, conflict.removes().len(), conflict.adds().len()), parse_conflict(materialized.as_bytes(), conflict.removes().len(), conflict.adds().len()),
@r###" @r###"
Some( Some(
[ [
@ -661,9 +660,8 @@ fn test_update_conflict_from_content() {
// If the content is unchanged compared to the materialized value, we get the // If the content is unchanged compared to the materialized value, we get the
// old conflict id back. // old conflict id back.
let mut materialized = vec![]; let materialized = materialize_conflict_string(store, &path, &conflict);
materialize(&conflict, store, &path, &mut materialized).unwrap(); let result = update_from_content(&conflict, store, &path, materialized.as_bytes()).unwrap();
let result = update_from_content(&conflict, store, &path, &materialized).unwrap();
assert_eq!(result, Some(conflict.clone())); assert_eq!(result, Some(conflict.clone()));
// If the conflict is resolved, we get None back to indicate that. // If the conflict is resolved, we get None back to indicate that.
@ -712,9 +710,8 @@ fn test_update_conflict_from_content_modify_delete() {
// If the content is unchanged compared to the materialized value, we get the // If the content is unchanged compared to the materialized value, we get the
// old conflict id back. // old conflict id back.
let mut materialized = vec![]; let materialized = materialize_conflict_string(store, &path, &conflict);
materialize(&conflict, store, &path, &mut materialized).unwrap(); let result = update_from_content(&conflict, store, &path, materialized.as_bytes()).unwrap();
let result = update_from_content(&conflict, store, &path, &materialized).unwrap();
assert_eq!(result, Some(conflict.clone())); assert_eq!(result, Some(conflict.clone()));
// If the conflict is resolved, we get None back to indicate that. // If the conflict is resolved, we get None back to indicate that.