next: make test cases test what they were supposed to

This commit is contained in:
Martin von Zweigbergk 2024-06-20 19:09:11 -07:00 committed by Martin von Zweigbergk
parent 741fa8dfe2
commit d8cd38a3a8

View file

@ -641,38 +641,35 @@ fn test_prev_conflict_editing() {
#[test] #[test]
fn test_next_conflict() { fn test_next_conflict() {
// There is a conflict in the second commit, so after next it should be the new // There is a conflict in the third commit, so after next it should be the new
// parent. // parent.
let test_env = TestEnvironment::default(); let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]); test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo"); let repo_path = test_env.env_root().join("repo");
let file_path = repo_path.join("content.txt"); let file_path = repo_path.join("content.txt");
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
std::fs::write(&file_path, "second").unwrap();
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
// Create a conflict in the second commit.
test_env.jj_cmd_ok(&repo_path, &["edit", "description(first)"]);
std::fs::write(&file_path, "first").unwrap(); std::fs::write(&file_path, "first").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "first"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "second"]);
// Create a conflict in the third commit.
std::fs::write(&file_path, "third").unwrap();
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]); test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "third"]);
test_env.jj_cmd_ok(&repo_path, &["new", "description(second)"]); test_env.jj_cmd_ok(&repo_path, &["new", "description(first)"]);
std::fs::write(&file_path, "first v2").unwrap();
test_env.jj_cmd_ok(&repo_path, &["squash", "--into", "description(third)"]);
// Test the setup // Test the setup
// TODO: This test doesn't seem to test what it's supposed to (we're already on
// the second commit)
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ yqosqzytrlsw conflict @ royxmykxtrkr
mzvwutvlkqwt conflict third kkmpptxzrspx conflict third
rlvkpnrzqnoo second
rlvkpnrzqnoo conflict second
qpvuntsmwlqt first qpvuntsmwlqt first
zzzzzzzzzzzz zzzzzzzzzzzz
"###); "###);
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]); test_env.jj_cmd_ok(&repo_path, &["next", "--conflict"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ yostqsxwqrlt conflict @ vruxwmqvtpmx conflict
mzvwutvlkqwt conflict third kkmpptxzrspx conflict third
rlvkpnrzqnoo second
rlvkpnrzqnoo conflict second
qpvuntsmwlqt first qpvuntsmwlqt first
zzzzzzzzzzzz zzzzzzzzzzzz
"###); "###);
@ -693,22 +690,17 @@ fn test_next_conflict_editing() {
std::fs::write(&file_path, "third").unwrap(); std::fs::write(&file_path, "third").unwrap();
test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]); test_env.jj_cmd_ok(&repo_path, &["edit", "description(second)"]);
std::fs::write(&file_path, "modified second").unwrap(); std::fs::write(&file_path, "modified second").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@+"]); test_env.jj_cmd_ok(&repo_path, &["edit", "@-"]);
// Test the setup // Test the setup
// TODO: This test doesn't seem to test what it's supposed to (we're already on
// top of the third commit)
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ mzvwutvlkqwt conflict
kkmpptxzrspx conflict kkmpptxzrspx conflict
rlvkpnrzqnoo second rlvkpnrzqnoo second
qpvuntsmwlqt first @ qpvuntsmwlqt first
zzzzzzzzzzzz zzzzzzzzzzzz
"###); "###);
test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]); test_env.jj_cmd_ok(&repo_path, &["next", "--conflict", "--edit"]);
// We now should be editing the third commit.
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###" insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ yqosqzytrlsw conflict @ kkmpptxzrspx conflict
kkmpptxzrspx conflict
rlvkpnrzqnoo second rlvkpnrzqnoo second
qpvuntsmwlqt first qpvuntsmwlqt first
zzzzzzzzzzzz zzzzzzzzzzzz