mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 14:57:14 +00:00
conflicts: use snapshot testing for conflict-parsing
This commit is contained in:
parent
a28396fc86
commit
fe0eb9137c
1 changed files with 45 additions and 25 deletions
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
use jujutsu_lib::backend::{Conflict, ConflictTerm, FileId, TreeValue};
|
use jujutsu_lib::backend::{Conflict, ConflictTerm, FileId, 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::{ConflictHunk, MergeHunk};
|
|
||||||
use jujutsu_lib::repo::Repo;
|
use jujutsu_lib::repo::Repo;
|
||||||
use jujutsu_lib::repo_path::RepoPath;
|
use jujutsu_lib::repo_path::RepoPath;
|
||||||
use jujutsu_lib::store::Store;
|
use jujutsu_lib::store::Store;
|
||||||
|
@ -231,7 +230,7 @@ line 5
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_conflict_simple() {
|
fn test_parse_conflict_simple() {
|
||||||
assert_eq!(
|
insta::assert_debug_snapshot!(
|
||||||
parse_conflict(
|
parse_conflict(
|
||||||
b"line 1
|
b"line 1
|
||||||
<<<<<<<
|
<<<<<<<
|
||||||
|
@ -248,20 +247,33 @@ line 5
|
||||||
1,
|
1,
|
||||||
2
|
2
|
||||||
),
|
),
|
||||||
Some(vec![
|
@r###"
|
||||||
MergeHunk::Resolved(b"line 1\n".to_vec()),
|
Some(
|
||||||
MergeHunk::Conflict(ConflictHunk {
|
[
|
||||||
removes: vec![b"line 2\nline 3\nline 4\n".to_vec()],
|
Resolved(
|
||||||
adds: vec![b"line 2\nleft\nline 4\n".to_vec(), b"right\n".to_vec()]
|
"line 1\n",
|
||||||
}),
|
),
|
||||||
MergeHunk::Resolved(b"line 5\n".to_vec())
|
Conflict {
|
||||||
])
|
removes: [
|
||||||
|
"line 2\nline 3\nline 4\n",
|
||||||
|
],
|
||||||
|
adds: [
|
||||||
|
"line 2\nleft\nline 4\n",
|
||||||
|
"right\n",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
Resolved(
|
||||||
|
"line 5\n",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
"###
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_conflict_multi_way() {
|
fn test_parse_conflict_multi_way() {
|
||||||
assert_eq!(
|
insta::assert_debug_snapshot!(
|
||||||
parse_conflict(
|
parse_conflict(
|
||||||
b"line 1
|
b"line 1
|
||||||
<<<<<<<
|
<<<<<<<
|
||||||
|
@ -283,21 +295,29 @@ line 5
|
||||||
2,
|
2,
|
||||||
3
|
3
|
||||||
),
|
),
|
||||||
Some(vec![
|
@r###"
|
||||||
MergeHunk::Resolved(b"line 1\n".to_vec()),
|
Some(
|
||||||
MergeHunk::Conflict(ConflictHunk {
|
[
|
||||||
removes: vec![
|
Resolved(
|
||||||
b"line 2\nline 3\nline 4\n".to_vec(),
|
"line 1\n",
|
||||||
b"line 2\nline 3\nline 4\n".to_vec()
|
),
|
||||||
|
Conflict {
|
||||||
|
removes: [
|
||||||
|
"line 2\nline 3\nline 4\n",
|
||||||
|
"line 2\nline 3\nline 4\n",
|
||||||
],
|
],
|
||||||
adds: vec![
|
adds: [
|
||||||
b"line 2\nleft\nline 4\n".to_vec(),
|
"line 2\nleft\nline 4\n",
|
||||||
b"right\n".to_vec(),
|
"right\n",
|
||||||
b"line 2\nforward\nline 3\nline 4\n".to_vec()
|
"line 2\nforward\nline 3\nline 4\n",
|
||||||
]
|
],
|
||||||
}),
|
},
|
||||||
MergeHunk::Resolved(b"line 5\n".to_vec())
|
Resolved(
|
||||||
])
|
"line 5\n",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
"###
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue