gitbutler/crates/gitbutler-branch-actions/tests/virtual_branches/unapply_ownership.rs
Sebastian Thiel 9e236e3469
remove async except for in gitbutler-git
The reason is that it's unclear if maybe it's there for a good reason,
and I don't want to break the complex code in there.
2024-07-28 20:47:35 +02:00

58 lines
1.3 KiB
Rust

use std::fs;
use gitbutler_branch::{BranchCreateRequest, BranchOwnershipClaims};
use super::Test;
#[test]
fn should_unapply_with_commits() {
let Test {
project,
controller,
repository,
..
} = &Test::default();
controller
.set_base_branch(project, &"refs/remotes/origin/master".parse().unwrap())
.unwrap();
let branch_id = controller
.create_virtual_branch(project, &BranchCreateRequest::default())
.unwrap();
fs::write(
repository.path().join("file.txt"),
"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n",
)
.unwrap();
controller
.create_commit(project, branch_id, "test", None, false)
.unwrap();
// change in the committed hunks leads to hunk locking
fs::write(
repository.path().join("file.txt"),
"_\n2\n3\n4\n5\n6\n7\n8\n9\n_\n",
)
.unwrap();
controller
.unapply_ownership(
project,
&"file.txt:1-5,7-11"
.parse::<BranchOwnershipClaims>()
.unwrap(),
)
.unwrap_or_else(|err| panic!("{err:?}"));
let branch = controller
.list_virtual_branches(project)
.unwrap()
.0
.into_iter()
.find(|b| b.id == branch_id)
.unwrap();
assert!(branch.files.is_empty());
}