Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
bin: Add app test fixtures
Erik Kundt committed 1 year ago
commit 1917ca1c4a20574ea1c79a38b057e8a6b96a8ec8
parent de643c5
4 files changed +51 -1
modified Cargo.lock
@@ -1627,6 +1627,15 @@ dependencies = [
]

[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -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",
modified Cargo.toml
@@ -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"

\ No newline at end of file
+
pretty_assertions = "^1.4.1"
+
radicle = { version = "0.14.0", features = ["test"]}

\ No newline at end of file
modified bin/main.rs
@@ -3,6 +3,8 @@ mod commands;
mod git;
mod log;
mod settings;
+
#[cfg(test)]
+
mod test;
mod ui;

use std::ffi::OsString;
added bin/test.rs
@@ -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)
+
    }
+
}