cli: fix move/squash/unsquash tests to run without source commit description

And ensure that editor isn't invoked in those cases.
This commit is contained in:
Yuya Nishihara 2022-12-21 13:33:21 +09:00
parent c9ff99d166
commit b474fc6ab5
3 changed files with 6 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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