forked from mirrors/jj
tests: extract helper that renders colored commit template
This commit is contained in:
parent
0e90cdedbc
commit
1883d62805
1 changed files with 21 additions and 13 deletions
|
@ -208,19 +208,7 @@ fn test_templater_label_function() {
|
|||
let test_env = TestEnvironment::default();
|
||||
test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
let render = |template| {
|
||||
test_env.jj_cmd_success(
|
||||
&repo_path,
|
||||
&[
|
||||
"log",
|
||||
"--color=always",
|
||||
"--no-graph",
|
||||
"-r@-",
|
||||
"-T",
|
||||
template,
|
||||
],
|
||||
)
|
||||
};
|
||||
let render = |template| get_colored_template_output(&test_env, &repo_path, "@-", template);
|
||||
|
||||
// Literal
|
||||
insta::assert_snapshot!(render(r#"label("error", "text")"#), @"[38;5;1mtext[39m");
|
||||
|
@ -242,3 +230,23 @@ fn get_template_output(
|
|||
) -> String {
|
||||
test_env.jj_cmd_success(repo_path, &["log", "--no-graph", "-r", rev, "-T", template])
|
||||
}
|
||||
|
||||
fn get_colored_template_output(
|
||||
test_env: &TestEnvironment,
|
||||
repo_path: &Path,
|
||||
rev: &str,
|
||||
template: &str,
|
||||
) -> String {
|
||||
test_env.jj_cmd_success(
|
||||
repo_path,
|
||||
&[
|
||||
"log",
|
||||
"--color=always",
|
||||
"--no-graph",
|
||||
"-r",
|
||||
rev,
|
||||
"-T",
|
||||
template,
|
||||
],
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue