mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-11 06:42:47 +00:00
tests: assert paths of initialized GitBackend
This commit is contained in:
parent
ce46c10c96
commit
77e16243d6
1 changed files with 22 additions and 6 deletions
|
@ -53,15 +53,24 @@ fn test_init_internal_git() {
|
||||||
let temp_dir = testutils::new_temp_dir();
|
let temp_dir = testutils::new_temp_dir();
|
||||||
let (canonical, uncanonical) = canonicalize(temp_dir.path());
|
let (canonical, uncanonical) = canonicalize(temp_dir.path());
|
||||||
let (workspace, repo) = Workspace::init_internal_git(&settings, &uncanonical).unwrap();
|
let (workspace, repo) = Workspace::init_internal_git(&settings, &uncanonical).unwrap();
|
||||||
assert!(repo
|
let git_backend = repo
|
||||||
.store()
|
.store()
|
||||||
.backend_impl()
|
.backend_impl()
|
||||||
.downcast_ref::<GitBackend>()
|
.downcast_ref::<GitBackend>()
|
||||||
.is_some());
|
.unwrap();
|
||||||
assert_eq!(repo.repo_path(), &canonical.join(".jj").join("repo"));
|
assert_eq!(repo.repo_path(), &canonical.join(".jj").join("repo"));
|
||||||
assert_eq!(workspace.workspace_root(), &canonical);
|
assert_eq!(workspace.workspace_root(), &canonical);
|
||||||
|
assert_eq!(
|
||||||
|
git_backend.git_repo_path(),
|
||||||
|
canonical.join(PathBuf::from_iter([".jj", "repo", "store", "git"])),
|
||||||
|
);
|
||||||
|
assert!(git_backend.git_workdir().is_none());
|
||||||
|
assert_eq!(
|
||||||
|
std::fs::read_to_string(repo.repo_path().join("store").join("git_target")).unwrap(),
|
||||||
|
"git"
|
||||||
|
);
|
||||||
|
|
||||||
// Just test that we ca write a commit to the store
|
// Just test that we can write a commit to the store
|
||||||
let mut tx = repo.start_transaction(&settings, "test");
|
let mut tx = repo.start_transaction(&settings, "test");
|
||||||
write_random_commit(tx.mut_repo(), &settings);
|
write_random_commit(tx.mut_repo(), &settings);
|
||||||
}
|
}
|
||||||
|
@ -76,17 +85,24 @@ fn test_init_external_git() {
|
||||||
std::fs::create_dir(uncanonical.join("jj")).unwrap();
|
std::fs::create_dir(uncanonical.join("jj")).unwrap();
|
||||||
let (workspace, repo) =
|
let (workspace, repo) =
|
||||||
Workspace::init_external_git(&settings, &uncanonical.join("jj"), &git_repo_path).unwrap();
|
Workspace::init_external_git(&settings, &uncanonical.join("jj"), &git_repo_path).unwrap();
|
||||||
|
let git_backend = repo
|
||||||
assert!(repo
|
|
||||||
.store()
|
.store()
|
||||||
.backend_impl()
|
.backend_impl()
|
||||||
.downcast_ref::<GitBackend>()
|
.downcast_ref::<GitBackend>()
|
||||||
.is_some());
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
repo.repo_path(),
|
repo.repo_path(),
|
||||||
&canonical.join("jj").join(".jj").join("repo")
|
&canonical.join("jj").join(".jj").join("repo")
|
||||||
);
|
);
|
||||||
assert_eq!(workspace.workspace_root(), &canonical.join("jj"));
|
assert_eq!(workspace.workspace_root(), &canonical.join("jj"));
|
||||||
|
assert_eq!(
|
||||||
|
git_backend.git_repo_path(),
|
||||||
|
canonical.join("git").join(".git")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
git_backend.git_workdir(),
|
||||||
|
Some(canonical.join("git").as_ref())
|
||||||
|
);
|
||||||
|
|
||||||
// Just test that we can write a commit to the store
|
// Just test that we can write a commit to the store
|
||||||
let mut tx = repo.start_transaction(&settings, "test");
|
let mut tx = repo.start_transaction(&settings, "test");
|
||||||
|
|
Loading…
Reference in a new issue