cli: use insta snapshot to test editor error messages

This commit is contained in:
Yuya Nishihara 2025-01-01 16:09:26 +09:00
parent d5b0aa20cb
commit e344c21a28

View file

@ -139,7 +139,11 @@ fn test_describe() {
// Fails if the editor fails
std::fs::write(&edit_script, "fail").unwrap();
let stderr = test_env.jj_cmd_failure(&repo_path, &["describe"]);
assert!(stderr.contains("exited with an error"));
insta::with_settings!({
filters => [(r"\bEditor '[^']*'", "Editor '<redacted>'")],
}, {
insta::assert_snapshot!(stderr, @"Error: Editor '<redacted>' exited with an error");
});
// ignore everything after the first ignore-rest line
std::fs::write(
@ -412,7 +416,11 @@ fn test_describe_multiple_commits() {
// Fails if the editor fails
std::fs::write(&edit_script, "fail").unwrap();
let stderr = test_env.jj_cmd_failure(&repo_path, &["describe", "@", "@-"]);
assert!(stderr.contains("exited with an error"));
insta::with_settings!({
filters => [(r"\bEditor '[^']*'", "Editor '<redacted>'")],
}, {
insta::assert_snapshot!(stderr, @"Error: Editor '<redacted>' exited with an error");
});
// describe lines should take priority over ignore-rest
std::fs::write(