Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: add rad fetch example test
Fintan Halpenny committed 3 years ago
commit 3b49a7911b50f1002fe5c724ec4d6e657e833325
parent ea03e8a38bb9e7837f5a54129ed094df82a6d6be
2 files changed +61 -0
added radicle-cli/examples/rad-fetch.md
@@ -0,0 +1,27 @@
+
Using `rad clone` is useful if we want to create and fetch a project
+
that exists on Radicle, but perhaps we're in a scenario where we may
+
already have an existing Git repository and so a full clone is not
+
necessary.
+

+
Instead, we want to fetch the project from the network into our local
+
storage. In this scenario, we know that the project is
+
`rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji`. In order to fetch it, we first
+
have to track the project.
+

+
```
+
$ rad track rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Tracking policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'trusted'
+
! Warning: fetch after track is not yet supported
+
```
+

+
Now that the project is tracked we can fetch it and we will have it in
+
our local storage.
+

+
```
+
$ rad fetch rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6MknSL…StBU8Vi..
+
✓ Fetched repository from 1 seed(s)
+
```
+

+
However, we don't have a local fork of the project. We can follow this
+
up with [rad-fork][rad-fork.md].
modified radicle-cli/tests/commands.rs
@@ -395,6 +395,40 @@ fn rad_init_sync_and_clone() {
}

#[test]
+
fn rad_fetch() {
+
    let mut environment = Environment::new();
+
    let working = environment.tmp().join("working");
+
    let alice = environment.node("alice");
+
    let bob = environment.node("bob");
+

+
    let mut alice = alice.spawn(Config::default());
+
    let bob = bob.spawn(Config::default());
+

+
    alice.connect(&bob);
+
    fixtures::repository(working.join("alice"));
+

+
    // Alice initializes a repo after her node has started, and after bob has connected to it.
+
    test(
+
        "examples/rad-init-sync.md",
+
        &working.join("alice"),
+
        Some(&alice.home),
+
        [],
+
    )
+
    .unwrap();
+

+
    // Wait for bob to get any updates to the routing table.
+
    bob.converge([&alice]);
+

+
    test(
+
        "examples/rad-fetch.md",
+
        working.join("bob"),
+
        Some(&bob.home),
+
        [],
+
    )
+
    .unwrap();
+
}
+

+
#[test]
// User tries to clone; no seeds are available, but user has the repo locally.
fn test_clone_without_seeds() {
    logger::init(log::Level::Debug);