From b45da80c12221dd41528a8cf2d3e7898cf947ee9 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 26 Aug 2023 14:59:50 +0900 Subject: [PATCH] tests: add more tests for empty signature As I'm going to change the Signature type to not fill out a placeholder message, we need to test the builtin templates as well. --- cli/tests/test_commit_template.rs | 30 ++++++++++++++++++++++++++---- cli/tests/test_templater.rs | 14 ++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 5244f6c87..c11d69211 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -172,26 +172,48 @@ fn test_log_builtin_templates() { let repo_path = test_env.env_root().join("repo"); let render = |template| test_env.jj_cmd_success(&repo_path, &["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###" - @ qpvuntsm test.user 2001-02-03 04:05:07.000 +07:00 230dd059 (empty) (no description set) + @ rlvkpnrz (no username available) 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###" - @ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + @ rlvkpnrz (no email available) 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###" - @ qpvuntsm test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059 + @ rlvkpnrz (no email available) 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: 230dd059e1b059aefc0da06a2e5a7dbf22362f22 + @ Commit ID: dc31539712c7294d1d712cec63cef4504b94ca74 + │ Change ID: rlvkpnrzqnoowoytxnquwvuryrwnrmlp + │ Author: (no name available) <(no email available)> (2001-02-03 04:05:08.000 +07:00) + │ Committer: (no name available) <(no email available)> (2001-02-03 04:05:08.000 +07:00) + │ + │ (no description set) + │ + ◉ Commit ID: 230dd059e1b059aefc0da06a2e5a7dbf22362f22 │ Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu │ Author: Test User (2001-02-03 04:05:07.000 +07:00) │ Committer: Test User (2001-02-03 04:05:07.000 +07:00) diff --git a/cli/tests/test_templater.rs b/cli/tests/test_templater.rs index 490ebe371..022c9df39 100644 --- a/cli/tests/test_templater.rs +++ b/cli/tests/test_templater.rs @@ -474,6 +474,20 @@ fn test_templater_signature() { insta::assert_snapshot!(render(r#"author.name()"#), @"Test User"); insta::assert_snapshot!(render(r#"author.email()"#), @"(no email available)"); insta::assert_snapshot!(render(r#"author.username()"#), @"(no username available)"); + + test_env.jj_cmd_ok( + &repo_path, + &[ + "--config-toml=user.email=''", + "--config-toml=user.name=''", + "new", + ], + ); + + insta::assert_snapshot!(render(r#"author"#), @"(no name available) <(no email available)>"); + insta::assert_snapshot!(render(r#"author.name()"#), @"(no name available)"); + insta::assert_snapshot!(render(r#"author.email()"#), @"(no email available)"); + insta::assert_snapshot!(render(r#"author.username()"#), @"(no username available)"); } #[test]