From a43c47a28cb4a5282493dc9f49606d9469fce947 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 9 Jan 2023 22:16:47 -0800 Subject: [PATCH] Move a test from `test_log_command` to `test_commit_template` --- tests/test_commit_template.rs | 22 +++++++++++++++++++--- tests/test_log_command.rs | 10 ---------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/test_commit_template.rs b/tests/test_commit_template.rs index aba54470b..d35b25409 100644 --- a/tests/test_commit_template.rs +++ b/tests/test_commit_template.rs @@ -52,17 +52,33 @@ fn test_log_author_timestamp_ago() { } #[test] -fn test_log_default_colors() { +fn test_log_default() { 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"); - test_env.jj_cmd_success(&repo_path, &["describe", "-m", "description 1"]); + std::fs::write(repo_path.join("file1"), "foo\n").unwrap(); + test_env.jj_cmd_success(&repo_path, &["describe", "-m", "add a file"]); + test_env.jj_cmd_success(&repo_path, &["new", "-m", "description 1"]); test_env.jj_cmd_success(&repo_path, &["branch", "create", "my-branch"]); + + // Test default log output format + insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["log"]), @r###" + @ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d + | description 1 + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 + | add a file + o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 + (no description set) + "###); + + // Color let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]); insta::assert_snapshot!(stdout, @r###" - @ 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 my-branch 45a3aa29e907 + @ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d | description 1 + o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 + | add a file o 000000000000  1970-01-01 00:00:00.000 +00:00 000000000000 (no description set) "###); diff --git a/tests/test_log_command.rs b/tests/test_log_command.rs index d744c7651..b73158774 100644 --- a/tests/test_log_command.rs +++ b/tests/test_log_command.rs @@ -60,16 +60,6 @@ fn test_log_with_or_without_diff() { o (no description set) "###); - // Test default log output format - insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["log"]), @r###" - @ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:10.000 +07:00 789e536fd2e0 - | a new commit - o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97 - | add a file - o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000 - (no description set) - "###); - let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-T", "description", "--no-graph"]); insta::assert_snapshot!(stdout, @r###" a new commit