Files
radicle-tui/bin/test.rs
T
2024-12-11 11:52:40 +01:00

36 lines
975 B
Rust

pub mod fixtures {
use anyhow::Result;
use radicle::cob::cache::NoCache;
use radicle::patch::{Cache, MergeTarget, PatchMut, Patches};
use radicle::storage::git::Repository;
use radicle::test::setup::{BranchWith, NodeWithRepo};
pub fn node_with_repo() -> NodeWithRepo {
NodeWithRepo::default()
}
pub fn branch(node: &NodeWithRepo) -> BranchWith {
let checkout = node.repo.checkout();
checkout.branch_with([("README", b"Hello World!")])
}
pub fn patch<'a, 'g>(
node: &'a NodeWithRepo,
branch: &BranchWith,
patches: &'a mut Cache<Patches<'a, Repository>, NoCache>,
) -> Result<PatchMut<'a, 'g, Repository, NoCache>> {
let patch = patches.create(
"My first patch",
"Blah blah blah.",
MergeTarget::Delegates,
branch.base,
branch.oid,
&[],
&node.signer,
)?;
Ok(patch)
}
}