Skip to content

Commit

Permalink
tests: assert paths of initialized GitBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Nov 4, 2023
1 parent c8e2e61 commit 71ec971
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/tests/test_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,24 @@ fn test_init_internal_git() {
let temp_dir = testutils::new_temp_dir();
let (canonical, uncanonical) = canonicalize(temp_dir.path());
let (workspace, repo) = Workspace::init_internal_git(&settings, &uncanonical).unwrap();
assert!(repo
let git_backend = repo
.store()
.backend_impl()
.downcast_ref::<GitBackend>()
.is_some());
.unwrap();
assert_eq!(repo.repo_path(), &canonical.join(".jj").join("repo"));
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");
write_random_commit(tx.mut_repo(), &settings);
}
Expand All @@ -76,17 +85,24 @@ fn test_init_external_git() {
std::fs::create_dir(uncanonical.join("jj")).unwrap();
let (workspace, repo) =
Workspace::init_external_git(&settings, &uncanonical.join("jj"), &git_repo_path).unwrap();

assert!(repo
let git_backend = repo
.store()
.backend_impl()
.downcast_ref::<GitBackend>()
.is_some());
.unwrap();
assert_eq!(
repo.repo_path(),
&canonical.join("jj").join(".jj").join("repo")
);
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
let mut tx = repo.start_transaction(&settings, "test");
Expand Down

0 comments on commit 71ec971

Please sign in to comment.