From e344c21a28a66ba8b52be5674537fbff3bfb0231 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 1 Jan 2025 16:09:26 +0900 Subject: [PATCH] cli: use insta snapshot to test editor error messages --- cli/tests/test_describe_command.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cli/tests/test_describe_command.rs b/cli/tests/test_describe_command.rs index a730e86ea..b1dc1b103 100644 --- a/cli/tests/test_describe_command.rs +++ b/cli/tests/test_describe_command.rs @@ -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 ''")], + }, { + insta::assert_snapshot!(stderr, @"Error: Editor '' 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 ''")], + }, { + insta::assert_snapshot!(stderr, @"Error: Editor '' exited with an error"); + }); // describe lines should take priority over ignore-rest std::fs::write(