ok/jj
1
0
Fork 0
forked from mirrors/jj

tests: teach fake editor to check that initial text is as expected

This commit is contained in:
Martin von Zweigbergk 2022-08-28 21:07:51 -07:00 committed by Martin von Zweigbergk
parent 7dbb8e0fa2
commit 478dfd74fc
2 changed files with 12 additions and 2 deletions

View file

@ -37,6 +37,13 @@ fn main() {
match parts.as_slice() {
[""] => {}
["fail"] => exit(1),
["expect"] => {
let actual = String::from_utf8(std::fs::read(&args.file).unwrap()).unwrap();
if actual != payload {
eprintln!("unexpected content: {}", actual);
exit(1)
}
}
["write"] => {
std::fs::write(&args.file, payload).unwrap();
}

View file

@ -30,8 +30,11 @@ fn test_describe() {
Working copy now at: 7e0db3b0ad17 description from CLI
"###);
// Test making no changes
std::fs::write(&edit_script, "").unwrap();
// Check that the text file gets initialized with the current description and make no changes
std::fs::write(&edit_script, r#"expect
description from CLI
JJ: Lines starting with "JJ: " (like this one) will be removed.
"#).unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["describe"]);
insta::assert_snapshot!(stdout, @r###"
Working copy now at: 45bfa10db64d description from CLI