Skip to content

Commit

Permalink
tests: introduce conflicts in prev/next --conflict test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
noahmayr committed May 1, 2024
1 parent 46c0987 commit 63ba6f3
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions cli/tests/test_next_prev_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,18 @@ fn test_prev_conflict() {
std::fs::write(&file_path, "Other text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
// Create a conflict in the third commit, where we'll jump to.
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
std::fs::write(&file_path, "some text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict"]);
// We now should be a child of `third`.
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Working copy now at: zsuskuln 009f88bf (empty) fourth
Parent commit : kkmpptxz 3fa8931e (empty) third
Working copy now at: vruxwmqv 61428b9f (conflict) (empty) (no description set)
Parent commit : kkmpptxz 9de45eb7 (conflict) third
There are unresolved conflicts at these paths:
content.txt 2-sided conflict
"###);
}

Expand All @@ -602,14 +606,18 @@ fn test_prev_conflict_editing() {
std::fs::write(&file_path, "Other text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
// Create a conflict in the third commit, where we'll jump to.
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
std::fs::write(&file_path, "some text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["prev", "--conflict", "--edit"]);
// We now should be editing the third commit.
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Working copy now at: zsuskuln 009f88bf (empty) fourth
Parent commit : kkmpptxz 3fa8931e (empty) third
Working copy now at: royxmykx 311dd604 (conflict) fourth
Parent commit : kkmpptxz 9de45eb7 (conflict) third
There are unresolved conflicts at these paths:
content.txt 2-sided conflict
"###);
}

Expand All @@ -623,24 +631,26 @@ fn test_next_conflict() {
let file_path = repo_path.join("content.txt");
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
std::fs::write(&file_path, "Other text\n").unwrap();
// Create a conflict in the third commit.
std::fs::write(&file_path, "Other text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
std::fs::write(&file_path, "Sir, we've got a problem\n").unwrap();
// Create a conflict in the third commit.
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
std::fs::write(&file_path, "some text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "@---"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Working copy now at: kkmpptxz 3fa8931e (empty) third
Parent commit : rlvkpnrz 5c52832c (empty) second
Working copy now at: kkmpptxz 9de45eb7 (empty) third
Parent commit : rlvkpnrz 374aea34 (empty) second
"###);
// --edit is implied when already editing a non-head commit
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Working copy now at: zsuskuln 009f88bf (empty) fourth
Parent commit : kkmpptxz 3fa8931e (empty) third
Working copy now at: royxmykx 311dd604 (empty) fourth
Parent commit : kkmpptxz 9de45eb7 (empty) third
"###);
}

Expand All @@ -655,17 +665,19 @@ fn test_next_conflict_editing() {
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
std::fs::write(&file_path, "Other text").unwrap();
// Create a conflict in the third commit.
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
std::fs::write(&file_path, "Sir, we've got a problem").unwrap();
// Create a conflict in the third commit.
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
std::fs::write(&file_path, "some text").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "description(third)"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "fourth"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "@---"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]);
// We now should be editing the third commit.
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Working copy now at: kkmpptxz 3fa8931e (empty) third
Parent commit : rlvkpnrz 5c52832c (empty) second
Working copy now at: kkmpptxz 9de45eb7 (empty) third
Parent commit : rlvkpnrz 374aea34 (empty) second
"###);
}

Expand Down

0 comments on commit 63ba6f3

Please sign in to comment.