forked from mirrors/jj
tests: teach fake editor to check that initial text is as expected
This commit is contained in:
parent
7dbb8e0fa2
commit
478dfd74fc
2 changed files with 12 additions and 2 deletions
|
@ -37,6 +37,13 @@ fn main() {
|
||||||
match parts.as_slice() {
|
match parts.as_slice() {
|
||||||
[""] => {}
|
[""] => {}
|
||||||
["fail"] => exit(1),
|
["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"] => {
|
["write"] => {
|
||||||
std::fs::write(&args.file, payload).unwrap();
|
std::fs::write(&args.file, payload).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,11 @@ fn test_describe() {
|
||||||
Working copy now at: 7e0db3b0ad17 description from CLI
|
Working copy now at: 7e0db3b0ad17 description from CLI
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
// Test making no changes
|
// Check that the text file gets initialized with the current description and make no changes
|
||||||
std::fs::write(&edit_script, "").unwrap();
|
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"]);
|
let stdout = test_env.jj_cmd_success(&repo_path, &["describe"]);
|
||||||
insta::assert_snapshot!(stdout, @r###"
|
insta::assert_snapshot!(stdout, @r###"
|
||||||
Working copy now at: 45bfa10db64d description from CLI
|
Working copy now at: 45bfa10db64d description from CLI
|
||||||
|
|
Loading…
Reference in a new issue