test_merged_tree: nest each part of test_diff_dir_file()

I'm about to add a few more checks for diffing with a matcher. I think
it will help make it readable and reduce the risk of mixing up
variables between each part of the test if we use some nested blocks.

I also removed some unnecessary `.clone()` calls while at it.
This commit is contained in:
Martin von Zweigbergk 2023-11-04 15:51:39 -07:00 committed by Martin von Zweigbergk
parent c9ce80a82a
commit 16aa8e8f10

View file

@ -906,16 +906,12 @@ fn test_diff_dir_file() {
(&path6.join(&file), "right"),
],
);
let left_merged = MergedTree::new(Merge::new(
vec![left_base.clone()],
vec![left_side1.clone(), left_side2.clone()],
));
let right_merged = MergedTree::new(Merge::new(
vec![right_base.clone()],
vec![right_side1.clone(), right_side2.clone()],
));
let left_merged = MergedTree::new(Merge::new(vec![left_base], vec![left_side1, left_side2]));
let right_merged =
MergedTree::new(Merge::new(vec![right_base], vec![right_side1, right_side2]));
// Test the forwards diff
{
let actual_diff = left_merged
.diff(&right_merged, &EverythingMatcher)
.map(|(path, diff)| (path, diff.unwrap()))
@ -976,7 +972,10 @@ fn test_diff_dir_file() {
),
];
assert_eq!(actual_diff, expected_diff);
}
// Test the reverse diff
{
let actual_diff = right_merged
.diff(&left_merged, &EverythingMatcher)
.map(|(path, diff)| (path, diff.unwrap()))
@ -1038,6 +1037,7 @@ fn test_diff_dir_file() {
];
assert_eq!(actual_diff, expected_diff);
}
}
/// Merge 3 resolved trees that can be resolved
#[test]