From b474fc6ab5d22cf567319bb09de8db2ff6a5c9fb Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 21 Dec 2022 13:33:21 +0900 Subject: [PATCH] cli: fix move/squash/unsquash tests to run without source commit description And ensure that editor isn't invoked in those cases. --- tests/test_move_command.rs | 5 ++--- tests/test_squash_command.rs | 5 ++--- tests/test_unsquash_command.rs | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_move_command.rs b/tests/test_move_command.rs index 25682b50b..dceb1c227 100644 --- a/tests/test_move_command.rs +++ b/tests/test_move_command.rs @@ -331,7 +331,7 @@ fn test_move_description() { let repo_path = test_env.env_root().join("repo"); let edit_script = test_env.set_up_fake_editor(); - std::fs::write(&edit_script, r#""#).unwrap(); + std::fs::write(&edit_script, r#"fail"#).unwrap(); // If both descriptions are empty, the resulting description is empty std::fs::write(repo_path.join("file1"), "a\n").unwrap(); @@ -355,12 +355,11 @@ fn test_move_description() { // If the destination's description is non-empty and the source's description is // empty, the resulting description is from the destination - test_env.jj_cmd_success(&repo_path, &["undo"]); + test_env.jj_cmd_success(&repo_path, &["op", "restore", "@--"]); test_env.jj_cmd_success(&repo_path, &["describe", "@-", "-m", "destination"]); test_env.jj_cmd_success(&repo_path, &["move", "--to", "@-"]); insta::assert_snapshot!(get_description(&test_env, &repo_path, "@-"), @r###" destination - source "###); // If both descriptions were non-empty, we get asked for a combined description diff --git a/tests/test_squash_command.rs b/tests/test_squash_command.rs index e36bef9f6..74fba0eb0 100644 --- a/tests/test_squash_command.rs +++ b/tests/test_squash_command.rs @@ -247,7 +247,7 @@ fn test_squash_description() { let repo_path = test_env.env_root().join("repo"); let edit_script = test_env.set_up_fake_editor(); - std::fs::write(&edit_script, r#""#).unwrap(); + std::fs::write(&edit_script, r#"fail"#).unwrap(); // If both descriptions are empty, the resulting description is empty std::fs::write(repo_path.join("file1"), "a\n").unwrap(); @@ -271,12 +271,11 @@ fn test_squash_description() { // If the destination description is non-empty and the source's description is // empty, the resulting description is from the destination - test_env.jj_cmd_success(&repo_path, &["undo"]); + test_env.jj_cmd_success(&repo_path, &["op", "restore", "@--"]); test_env.jj_cmd_success(&repo_path, &["describe", "@-", "-m", "destination"]); test_env.jj_cmd_success(&repo_path, &["squash"]); insta::assert_snapshot!(get_description(&test_env, &repo_path, "@-"), @r###" destination - source "###); // If both descriptions were non-empty, we get asked for a combined description diff --git a/tests/test_unsquash_command.rs b/tests/test_unsquash_command.rs index 711d4c638..c0c4fc191 100644 --- a/tests/test_unsquash_command.rs +++ b/tests/test_unsquash_command.rs @@ -213,7 +213,7 @@ fn test_unsquash_description() { let repo_path = test_env.env_root().join("repo"); let edit_script = test_env.set_up_fake_editor(); - std::fs::write(&edit_script, r#""#).unwrap(); + std::fs::write(&edit_script, r#"fail"#).unwrap(); // If both descriptions are empty, the resulting description is empty std::fs::write(repo_path.join("file1"), "a\n").unwrap(); @@ -237,12 +237,11 @@ fn test_unsquash_description() { // If the destination description is non-empty and the source's description is // empty, the resulting description is from the destination - test_env.jj_cmd_success(&repo_path, &["undo"]); + test_env.jj_cmd_success(&repo_path, &["op", "restore", "@--"]); test_env.jj_cmd_success(&repo_path, &["describe", "-m", "destination"]); test_env.jj_cmd_success(&repo_path, &["unsquash"]); insta::assert_snapshot!(get_description(&test_env, &repo_path, "@"), @r###" destination - source "###); // If both descriptions were non-empty, we get asked for a combined description