mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 00:44:33 +00:00
tests: use snapshot testing for operation log
The operation IDs are now predictable in tests.
This commit is contained in:
parent
56f94e5192
commit
37e30a4b68
2 changed files with 15 additions and 17 deletions
|
@ -50,6 +50,17 @@ fn test_concurrent_operations_auto_rebase() {
|
|||
std::fs::write(repo_path.join("file"), "contents").unwrap();
|
||||
test_env.jj_cmd_success(&repo_path, &["describe", "-m", "initial"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
@ 72fc1a08c327 test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
| describe commit 123ed18e4c4c0d77428df41112bc02ffc83fb935
|
||||
| args: jj describe -m initial
|
||||
o b9a339dcd1dc test-username@host.example.com 2001-02-03 04:05:08.000 +07:00 - 2001-02-03 04:05:08.000 +07:00
|
||||
| commit working copy
|
||||
o a99a3fd5c51e test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
| add workspace 'default'
|
||||
o 56b94dfc38e7 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
initialize repo
|
||||
"###);
|
||||
let op_id_hex = stdout[2..14].to_string();
|
||||
|
||||
test_env.jj_cmd_success(&repo_path, &["describe", "-m", "rewritten"]);
|
||||
|
|
|
@ -25,10 +25,10 @@ fn test_op_log() {
|
|||
let repo_path = test_env.env_root().join("repo");
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["op", "log"]);
|
||||
insta::assert_snapshot!(redact_op_log(&stdout), @r###"
|
||||
@
|
||||
insta::assert_snapshot!(&stdout, @r###"
|
||||
@ a99a3fd5c51e test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
| add workspace 'default'
|
||||
o
|
||||
o 56b94dfc38e7 test-username@host.example.com 2001-02-03 04:05:07.000 +07:00 - 2001-02-03 04:05:07.000 +07:00
|
||||
initialize repo
|
||||
"###);
|
||||
let add_workspace_id = stdout[2..14].to_string();
|
||||
|
@ -98,7 +98,7 @@ fn test_op_log_configurable() {
|
|||
"#,
|
||||
);
|
||||
test_env
|
||||
.jj_cmd(&test_env.env_root(), &["init", "repo", "--git"])
|
||||
.jj_cmd(test_env.env_root(), &["init", "repo", "--git"])
|
||||
.env_remove("JJ_OP_HOSTNAME")
|
||||
.env_remove("JJ_OP_USERNAME")
|
||||
.assert()
|
||||
|
@ -115,16 +115,3 @@ fn get_log_output(test_env: &TestEnvironment, repo_path: &Path, op_id: &str) ->
|
|||
&["log", "-T", "commit_id", "--at-op", op_id, "-r", "all()"],
|
||||
)
|
||||
}
|
||||
|
||||
fn redact_op_log(stdout: &str) -> String {
|
||||
let mut lines = vec![];
|
||||
for line in stdout.lines() {
|
||||
if line.starts_with("@ ") || line.starts_with("o ") {
|
||||
// Redact everything -- operation ID, user, host, timestamps
|
||||
lines.push(line[..2].to_string());
|
||||
} else {
|
||||
lines.push(line.to_string());
|
||||
}
|
||||
}
|
||||
lines.join("\n")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue