forked from mirrors/jj
git: add test for exporting refs that fail
This adds a test for attempting to export both a branch called `main` and one called `main/sub` (#493), as well as for exporting a branch with an empty string as name (reported directly to me by @lkorinth).
This commit is contained in:
parent
2a87815006
commit
6a2f295ae4
1 changed files with 36 additions and 0 deletions
|
@ -699,6 +699,42 @@ fn test_export_conflicts() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_export_partial_failure() {
|
||||
// Check that we skip branches that fail to export
|
||||
let test_data = GitRepoData::create();
|
||||
let git_repo = test_data.git_repo;
|
||||
let mut tx = test_data
|
||||
.repo
|
||||
.start_transaction(&test_data.settings, "test");
|
||||
let mut_repo = tx.mut_repo();
|
||||
let commit_a =
|
||||
create_random_commit(&test_data.settings, &test_data.repo).write_to_repo(mut_repo);
|
||||
let target = RefTarget::Normal(commit_a.id().clone());
|
||||
// Empty string is disallowed by Git
|
||||
mut_repo.set_local_branch("".to_string(), target.clone());
|
||||
mut_repo.set_local_branch("main".to_string(), target.clone());
|
||||
// `main/sub` will conflict with `main` in Git, at least when using loose ref
|
||||
// storage
|
||||
mut_repo.set_local_branch("main/sub".to_string(), target);
|
||||
// TODO: this should succeed
|
||||
assert!(git::export_refs(mut_repo, &git_repo).is_err());
|
||||
|
||||
// The `main` branch should have succeeded but the other should have failed
|
||||
assert!(git_repo.find_reference("refs/heads/").is_err());
|
||||
assert!(git_repo.find_reference("refs/heads/main").is_err());
|
||||
assert!(git_repo.find_reference("refs/heads/main/sub").is_err());
|
||||
|
||||
// Now remove the `main` branch and make sure that the `main/sub` gets exported
|
||||
// even though it didn't change
|
||||
// TODO: this should succeed
|
||||
mut_repo.remove_local_branch("main");
|
||||
assert!(git::export_refs(mut_repo, &git_repo).is_err());
|
||||
assert!(git_repo.find_reference("refs/heads/").is_err());
|
||||
assert!(git_repo.find_reference("refs/heads/main").is_err());
|
||||
assert!(git_repo.find_reference("refs/heads/main/sub").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_init() {
|
||||
let settings = testutils::user_settings();
|
||||
|
|
Loading…
Reference in a new issue