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

tests: extract helper that renders colored commit template

This commit is contained in:
Yuya Nishihara 2023-02-03 22:13:56 +09:00
parent 0e90cdedbc
commit 1883d62805

View file

@ -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")"#), @"text");
@ -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,
],
)
}