From 1883d62805872ec8bf69c77d4107b45d6bd965f2 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 3 Feb 2023 22:13:56 +0900 Subject: [PATCH] tests: extract helper that renders colored commit template --- tests/test_templater.rs | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tests/test_templater.rs b/tests/test_templater.rs index 9961ad518..98da25b4b 100644 --- a/tests/test_templater.rs +++ b/tests/test_templater.rs @@ -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, + ], + ) +}