From dbf13a5250809a9d8793f8095791b38088672335 Mon Sep 17 00:00:00 2001 From: Vamsi Avula Date: Wed, 30 Aug 2023 10:00:20 +0530 Subject: [PATCH] tests: add test for log builtin templates with colors --- cli/tests/test_commit_template.rs | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 6597d29820..d22f1a4ccb 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -230,6 +230,72 @@ fn test_log_builtin_templates() { "###); } +#[test] +fn test_log_builtin_templates_colored() { + 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, &["--color=always", "log", "-T", template]); + + test_env.jj_cmd_ok( + &repo_path, + &[ + "--config-toml=user.email=''", + "--config-toml=user.name=''", + "new", + ], + ); + + insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###" + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 (empty) (no description set) + ◉ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) + ◉ zzzzzzzz root 00000000 + "###); + + insta::assert_snapshot!(render(r#"builtin_log_compact"#), @r###" + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + │ (empty) (no description set) + ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + │ (empty) (no description set) + ◉ zzzzzzzz root 00000000 + "###); + + insta::assert_snapshot!(render(r#"builtin_log_comfortable"#), @r###" + @ rlvkpnrz (no email set) 2001-02-03 04:05:08.000 +07:00 dc315397 + │ (empty) (no description set) + │ + ◉ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + │ (empty) (no description set) + │ + ◉ zzzzzzzz root 00000000 + "###); + + insta::assert_snapshot!(render(r#"builtin_log_detailed"#), @r###" + @ Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74 + │ Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp + │ Author: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) + │ Committer: (no name set) <(no email set)> (2001-02-03 04:05:08.000 +07:00) + │ + │  (no description set) + │ + ◉ Commit ID: 230dd059e1b059aefc0da06a2e5a7dbf22362f22 + │ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu + │ Author: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00) + │ Committer: Test User <test.user@example.com> (2001-02-03 04:05:07.000 +07:00) + │ + │  (no description set) + │ + ◉ Commit ID: 0000000000000000000000000000000000000000 + Change ID: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz + Author: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) + Committer: (no name set) <(no email set)> (1970-01-01 00:00:00.000 +00:00) + +  (no description set) + + "###); +} + #[test] fn test_log_obslog_divergence() { let test_env = TestEnvironment::default();