mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 18:27:38 +00:00
conflicts: use insta
in conflict tests
This commit is contained in:
parent
9dab88260a
commit
fc578a2dd7
1 changed files with 51 additions and 49 deletions
|
@ -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::conflicts::{materialize_conflict, parse_conflict, update_conflict_from_content};
|
||||||
use jujutsu_lib::files::MergeHunk;
|
use jujutsu_lib::files::MergeHunk;
|
||||||
use jujutsu_lib::repo_path::RepoPath;
|
use jujutsu_lib::repo_path::RepoPath;
|
||||||
|
use jujutsu_lib::store::Store;
|
||||||
use jujutsu_lib::testutils;
|
use jujutsu_lib::testutils;
|
||||||
use jujutsu_lib::testutils::TestRepo;
|
use jujutsu_lib::testutils::TestRepo;
|
||||||
|
|
||||||
|
@ -78,23 +79,22 @@ line 5
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
let mut result: Vec<u8> = vec![];
|
insta::assert_snapshot!(
|
||||||
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
|
&materialize_conflict_string(store, &path, &conflict),
|
||||||
assert_eq!(
|
@r###"
|
||||||
String::from_utf8(result).unwrap().as_str(),
|
line 1
|
||||||
"line 1
|
line 2
|
||||||
line 2
|
<<<<<<<
|
||||||
<<<<<<<
|
-------
|
||||||
-------
|
+++++++
|
||||||
+++++++
|
-line 3
|
||||||
-line 3
|
+left
|
||||||
+left
|
+++++++
|
||||||
+++++++
|
right
|
||||||
right
|
>>>>>>>
|
||||||
>>>>>>>
|
line 4
|
||||||
line 4
|
line 5
|
||||||
line 5
|
"###
|
||||||
"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,22 +156,19 @@ line 5
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
let mut result: Vec<u8> = vec![];
|
insta::assert_snapshot!(&materialize_conflict_string(store, &path, &conflict), @r###"
|
||||||
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
|
line 1
|
||||||
assert_eq!(
|
line 2
|
||||||
String::from_utf8(result).unwrap().as_str(),
|
<<<<<<<
|
||||||
"line 1
|
-------
|
||||||
line 2
|
+++++++
|
||||||
<<<<<<<
|
-line 3
|
||||||
-------
|
+left
|
||||||
+++++++
|
+++++++
|
||||||
-line 3
|
>>>>>>>
|
||||||
+left
|
line 4
|
||||||
+++++++
|
line 5
|
||||||
>>>>>>>
|
"###
|
||||||
line 4
|
|
||||||
line 5
|
|
||||||
"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,22 +231,21 @@ line 5
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result: Vec<u8> = vec![];
|
insta::assert_snapshot!(
|
||||||
materialize_conflict(store, &path, &conflict, &mut result).unwrap();
|
&materialize_conflict_string(store, &path, &conflict),
|
||||||
assert_eq!(
|
@r###"
|
||||||
String::from_utf8(result).unwrap().as_str(),
|
line 1
|
||||||
"line 1
|
line 2
|
||||||
line 2
|
<<<<<<<
|
||||||
<<<<<<<
|
-------
|
||||||
-------
|
+++++++
|
||||||
+++++++
|
-line 3
|
||||||
-line 3
|
+++++++
|
||||||
+++++++
|
right
|
||||||
right
|
>>>>>>>
|
||||||
>>>>>>>
|
line 4
|
||||||
line 4
|
line 5
|
||||||
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()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue