mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-05 23:42:50 +00:00
tests: port test_acls.rs to TestWorkDir API
This commit is contained in:
parent
d5d4c7fe79
commit
76e9342bbb
@ -20,25 +20,25 @@ use crate::common::TestEnvironment;
|
|||||||
fn test_diff() {
|
fn test_diff() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
test_env.run_jj_in(".", ["git", "init", "repo"]).success();
|
test_env.run_jj_in(".", ["git", "init", "repo"]).success();
|
||||||
let repo_path = test_env.env_root().join("repo");
|
let work_dir = test_env.work_dir("repo");
|
||||||
|
|
||||||
std::fs::create_dir(repo_path.join("dir")).unwrap();
|
work_dir.create_dir("dir");
|
||||||
std::fs::write(repo_path.join("a-first"), "foo\n").unwrap();
|
work_dir.write_file("a-first", "foo\n");
|
||||||
std::fs::write(repo_path.join("deleted-secret"), "foo\n").unwrap();
|
work_dir.write_file("deleted-secret", "foo\n");
|
||||||
std::fs::write(repo_path.join("dir").join("secret"), "foo\n").unwrap();
|
work_dir.write_file("dir/secret", "foo\n");
|
||||||
std::fs::write(repo_path.join("modified-secret"), "foo\n").unwrap();
|
work_dir.write_file("modified-secret", "foo\n");
|
||||||
std::fs::write(repo_path.join("z-last"), "foo\n").unwrap();
|
work_dir.write_file("z-last", "foo\n");
|
||||||
test_env.run_jj_in(&repo_path, ["new"]).success();
|
work_dir.run_jj(["new"]).success();
|
||||||
std::fs::write(repo_path.join("a-first"), "bar\n").unwrap();
|
work_dir.write_file("a-first", "bar\n");
|
||||||
std::fs::remove_file(repo_path.join("deleted-secret")).unwrap();
|
work_dir.remove_file("deleted-secret");
|
||||||
std::fs::write(repo_path.join("added-secret"), "bar\n").unwrap();
|
work_dir.write_file("added-secret", "bar\n");
|
||||||
std::fs::write(repo_path.join("dir").join("secret"), "bar\n").unwrap();
|
work_dir.write_file("dir/secret", "bar\n");
|
||||||
std::fs::write(repo_path.join("modified-secret"), "bar\n").unwrap();
|
work_dir.write_file("modified-secret", "bar\n");
|
||||||
std::fs::write(repo_path.join("z-last"), "bar\n").unwrap();
|
work_dir.write_file("z-last", "bar\n");
|
||||||
|
|
||||||
SecretBackend::adopt_git_repo(&repo_path);
|
SecretBackend::adopt_git_repo(work_dir.root());
|
||||||
|
|
||||||
let output = test_env.run_jj_in(&repo_path, ["diff", "--color-words"]);
|
let output = work_dir.run_jj(["diff", "--color-words"]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
Modified regular file a-first:
|
Modified regular file a-first:
|
||||||
1 1: foobar
|
1 1: foobar
|
||||||
@ -50,7 +50,7 @@ fn test_diff() {
|
|||||||
1 1: foobar
|
1 1: foobar
|
||||||
[EOF]
|
[EOF]
|
||||||
");
|
");
|
||||||
let output = test_env.run_jj_in(&repo_path, ["diff", "--summary"]);
|
let output = work_dir.run_jj(["diff", "--summary"]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
M a-first
|
M a-first
|
||||||
C {a-first => added-secret}
|
C {a-first => added-secret}
|
||||||
@ -60,7 +60,7 @@ fn test_diff() {
|
|||||||
M z-last
|
M z-last
|
||||||
[EOF]
|
[EOF]
|
||||||
");
|
");
|
||||||
let output = test_env.run_jj_in(&repo_path, ["diff", "--types"]);
|
let output = work_dir.run_jj(["diff", "--types"]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
FF a-first
|
FF a-first
|
||||||
FF {a-first => added-secret}
|
FF {a-first => added-secret}
|
||||||
@ -70,7 +70,7 @@ fn test_diff() {
|
|||||||
FF z-last
|
FF z-last
|
||||||
[EOF]
|
[EOF]
|
||||||
");
|
");
|
||||||
let output = test_env.run_jj_in(&repo_path, ["diff", "--stat"]);
|
let output = work_dir.run_jj(["diff", "--stat"]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
a-first | 2 +-
|
a-first | 2 +-
|
||||||
{a-first => added-secret} | 2 +-
|
{a-first => added-secret} | 2 +-
|
||||||
@ -81,7 +81,7 @@ fn test_diff() {
|
|||||||
6 files changed, 3 insertions(+), 4 deletions(-)
|
6 files changed, 3 insertions(+), 4 deletions(-)
|
||||||
[EOF]
|
[EOF]
|
||||||
");
|
");
|
||||||
let output = test_env.run_jj_in(&repo_path, ["diff", "--git"]);
|
let output = work_dir.run_jj(["diff", "--git"]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
diff --git a/a-first b/a-first
|
diff --git a/a-first b/a-first
|
||||||
index 257cc5642c..5716ca5987 100644
|
index 257cc5642c..5716ca5987 100644
|
||||||
@ -105,16 +105,16 @@ fn test_diff() {
|
|||||||
fn test_file_list_show() {
|
fn test_file_list_show() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
test_env.run_jj_in(".", ["git", "init", "repo"]).success();
|
test_env.run_jj_in(".", ["git", "init", "repo"]).success();
|
||||||
let repo_path = test_env.env_root().join("repo");
|
let work_dir = test_env.work_dir("repo");
|
||||||
|
|
||||||
std::fs::write(repo_path.join("a-first"), "foo\n").unwrap();
|
work_dir.write_file("a-first", "foo\n");
|
||||||
std::fs::write(repo_path.join("secret"), "bar\n").unwrap();
|
work_dir.write_file("secret", "bar\n");
|
||||||
std::fs::write(repo_path.join("z-last"), "baz\n").unwrap();
|
work_dir.write_file("z-last", "baz\n");
|
||||||
|
|
||||||
SecretBackend::adopt_git_repo(&repo_path);
|
SecretBackend::adopt_git_repo(work_dir.root());
|
||||||
|
|
||||||
// "file list" should just work since it doesn't access file content
|
// "file list" should just work since it doesn't access file content
|
||||||
let output = test_env.run_jj_in(&repo_path, ["file", "list"]);
|
let output = work_dir.run_jj(["file", "list"]);
|
||||||
insta::assert_snapshot!(output, @r"
|
insta::assert_snapshot!(output, @r"
|
||||||
a-first
|
a-first
|
||||||
secret
|
secret
|
||||||
@ -122,7 +122,7 @@ fn test_file_list_show() {
|
|||||||
[EOF]
|
[EOF]
|
||||||
");
|
");
|
||||||
|
|
||||||
let output = test_env.run_jj_in(&repo_path, ["file", "show", "."]);
|
let output = work_dir.run_jj(["file", "show", "."]);
|
||||||
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
insta::assert_snapshot!(output.normalize_backslash(), @r"
|
||||||
foo
|
foo
|
||||||
baz
|
baz
|
||||||
|
Loading…
x
Reference in New Issue
Block a user