mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 00:56:23 +00:00
tests: use insta::assert_snapshot!() to capture description templates
This commit is contained in:
parent
d740f1801b
commit
d328adca7b
3 changed files with 66 additions and 74 deletions
|
@ -169,18 +169,17 @@ fn test_commit_with_default_description() {
|
||||||
○ 573b6df51aea TESTED=TODO
|
○ 573b6df51aea TESTED=TODO
|
||||||
◆ 000000000000
|
◆ 000000000000
|
||||||
"###);
|
"###);
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###"
|
||||||
r#"
|
|
||||||
|
|
||||||
TESTED=TODO
|
|
||||||
JJ: This commit contains the following changes:
|
|
||||||
JJ: A file1
|
|
||||||
JJ: A file2
|
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
TESTED=TODO
|
||||||
"#
|
JJ: This commit contains the following changes:
|
||||||
);
|
JJ: A file1
|
||||||
|
JJ: A file2
|
||||||
|
|
||||||
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -266,18 +266,17 @@ fn test_describe_default_description() {
|
||||||
Working copy now at: qpvuntsm 573b6df5 TESTED=TODO
|
Working copy now at: qpvuntsm 573b6df5 TESTED=TODO
|
||||||
Parent commit : zzzzzzzz 00000000 (empty) (no description set)
|
Parent commit : zzzzzzzz 00000000 (empty) (no description set)
|
||||||
"###);
|
"###);
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor")).unwrap(), @r###"
|
||||||
r#"
|
|
||||||
|
|
||||||
TESTED=TODO
|
|
||||||
JJ: This commit contains the following changes:
|
|
||||||
JJ: A file1
|
|
||||||
JJ: A file2
|
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
TESTED=TODO
|
||||||
"#
|
JJ: This commit contains the following changes:
|
||||||
);
|
JJ: A file1
|
||||||
|
JJ: A file2
|
||||||
|
|
||||||
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -182,28 +182,26 @@ fn test_split_with_non_empty_description() {
|
||||||
Parent commit : qpvuntsm 231a3c00 part 1
|
Parent commit : qpvuntsm 231a3c00 part 1
|
||||||
"###);
|
"###);
|
||||||
|
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r###"
|
||||||
r#"JJ: Enter a description for the first commit.
|
JJ: Enter a description for the first commit.
|
||||||
test
|
test
|
||||||
|
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file1
|
JJ: A file1
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
insta::assert_snapshot!(
|
||||||
assert_eq!(
|
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r###"
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(),
|
JJ: Enter a description for the second commit.
|
||||||
r#"JJ: Enter a description for the second commit.
|
test
|
||||||
test
|
|
||||||
|
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file2
|
JJ: A file2
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
|
||||||
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
|
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
|
||||||
@ kkmpptxzrspx false part 2
|
@ kkmpptxzrspx false part 2
|
||||||
○ qpvuntsmwlqt false part 1
|
○ qpvuntsmwlqt false part 1
|
||||||
|
@ -244,18 +242,17 @@ fn test_split_with_default_description() {
|
||||||
// prompted to add a description to the first commit, which will use the
|
// prompted to add a description to the first commit, which will use the
|
||||||
// default value we set. The second commit will inherit the empty
|
// default value we set. The second commit will inherit the empty
|
||||||
// description from the commit being split.
|
// description from the commit being split.
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r###"
|
||||||
r#"JJ: Enter a description for the first commit.
|
JJ: Enter a description for the first commit.
|
||||||
|
|
||||||
|
|
||||||
TESTED=TODO
|
TESTED=TODO
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file1
|
JJ: A file1
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
|
||||||
assert!(!test_env.env_root().join("editor2").exists());
|
assert!(!test_env.env_root().join("editor2").exists());
|
||||||
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
|
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
|
||||||
@ kkmpptxzrspx false test_branch
|
@ kkmpptxzrspx false test_branch
|
||||||
|
@ -363,18 +360,17 @@ fn test_split_siblings_no_descendants() {
|
||||||
// prompted to add a description to the first commit, which will use the
|
// prompted to add a description to the first commit, which will use the
|
||||||
// default value we set. The second commit will inherit the empty
|
// default value we set. The second commit will inherit the empty
|
||||||
// description from the commit being split.
|
// description from the commit being split.
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r###"
|
||||||
r#"JJ: Enter a description for the first commit.
|
JJ: Enter a description for the first commit.
|
||||||
|
|
||||||
|
|
||||||
TESTED=TODO
|
TESTED=TODO
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file1
|
JJ: A file1
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
|
||||||
assert!(!test_env.env_root().join("editor2").exists());
|
assert!(!test_env.env_root().join("editor2").exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,28 +439,26 @@ fn test_split_siblings_with_descendants() {
|
||||||
|
|
||||||
// The commit we're splitting has a description, so the user will be
|
// The commit we're splitting has a description, so the user will be
|
||||||
// prompted to enter a description for each of the sibling commits.
|
// prompted to enter a description for each of the sibling commits.
|
||||||
assert_eq!(
|
insta::assert_snapshot!(
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(),
|
std::fs::read_to_string(test_env.env_root().join("editor1")).unwrap(), @r###"
|
||||||
r#"JJ: Enter a description for the first commit.
|
JJ: Enter a description for the first commit.
|
||||||
Add file1 & file2
|
Add file1 & file2
|
||||||
|
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file1
|
JJ: A file1
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
insta::assert_snapshot!(
|
||||||
assert_eq!(
|
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(), @r###"
|
||||||
std::fs::read_to_string(test_env.env_root().join("editor2")).unwrap(),
|
JJ: Enter a description for the second commit.
|
||||||
r#"JJ: Enter a description for the second commit.
|
Add file1 & file2
|
||||||
Add file1 & file2
|
|
||||||
|
|
||||||
JJ: This commit contains the following changes:
|
JJ: This commit contains the following changes:
|
||||||
JJ: A file2
|
JJ: A file2
|
||||||
|
|
||||||
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
JJ: Lines starting with "JJ: " (like this one) will be removed.
|
||||||
"#
|
"###);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test makes sure that the children of the commit being split retain any
|
// This test makes sure that the children of the commit being split retain any
|
||||||
|
|
Loading…
Reference in a new issue