bin: Add app test fixtures

This commit is contained in:
Erik Kundt
2024-12-11 11:52:40 +01:00
parent de643c5afa
commit 1917ca1c4a
4 changed files with 51 additions and 1 deletions
Generated
+12
View File
@@ -1626,6 +1626,15 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "qcheck"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b439bd4242da51d62d18c95e6a6add749346756b0d1a587dfd0cc22fa6b5f3f0"
dependencies = [
"rand",
]
[[package]]
name = "quote"
version = "1.0.35"
@@ -1655,6 +1664,7 @@ dependencies = [
"multibase",
"nonempty",
"once_cell",
"qcheck",
"radicle-cob",
"radicle-crypto",
"radicle-git-ext",
@@ -1752,7 +1762,9 @@ dependencies = [
"amplify",
"cyphernet",
"ec25519",
"fastrand",
"multibase",
"qcheck",
"radicle-git-ext",
"radicle-ssh",
"serde",
+2 -1
View File
@@ -53,4 +53,5 @@ tui-textarea = { version = "0.5.1", default-features = false, features = ["termi
tui-tree-widget = { version = "0.21.0" }
[dev-dependencies]
pretty_assertions = "^1.4.1"
pretty_assertions = "^1.4.1"
radicle = { version = "0.14.0", features = ["test"]}
+2
View File
@@ -3,6 +3,8 @@ mod commands;
mod git;
mod log;
mod settings;
#[cfg(test)]
mod test;
mod ui;
use std::ffi::OsString;
+35
View File
@@ -0,0 +1,35 @@
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)
}
}