Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
tests: add radicle command test for the rad remote
Vincenzo Palazzo committed 3 years ago
commit 5a4d0fff3fe3107441b93a7812ccfbffe11ed445
parent d55861572d21d6a055efebe535152244ce238fd3
5 files changed +79 -4
added radicle-cli/examples/rad-remote.md
@@ -0,0 +1,37 @@
+
Now, let's add a bob as a new remote:
+

+
```
+
$ rad remote add did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --name bob
+
✓ Remote bob added with rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
```
+

+
Now, we can see that there is a new remote in the list of remotes:
+

+
```
+
$ rad remote list
+
❲fetch❳ bob z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
❲fetch❳ rad z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
```
+

+
You can see both `bob` and `rad` as remotes.  The `rad` remote is our personal remote of the project.
+

+
When we're finished with the `bob` remote, we can remove it:
+

+
```
+
$ rad remote rm bob
+
✓ Remote `bob` removed
+
```
+

+
Now, add another time `bob` but without specify the `name`, so we should be able to fetch the node alias from our db!
+

+
```
+
$ rad remote add did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
✓ Remote bob added with rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
```
+

+
and then we remove again remote just added
+

+
```
+
$ rad remote rm bob
+
✓ Remote `bob` removed
+
```
modified radicle-cli/src/commands.rs
@@ -38,6 +38,8 @@ pub mod rad_patch;
pub mod rad_path;
#[path = "commands/push.rs"]
pub mod rad_push;
+
#[path = "commands/remote.rs"]
+
pub mod rad_remote;
#[path = "commands/review.rs"]
pub mod rad_review;
#[path = "commands/rm.rs"]
modified radicle-cli/src/commands/remote/add.rs
@@ -23,10 +23,7 @@ pub fn run(

    let url = Url::from(id).with_namespace(*pubkey);
    let remote = add_remote(repository, &name, &url)?;
-
    term::success!(
-
        "Remote {} added with {url}",
-
        remote.name,
-
    );
+
    term::success!("Remote {} added with {url}", remote.name,);
    Ok(())
}

modified radicle-cli/src/main.rs
@@ -337,6 +337,12 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
            rad_web::run,
            args.to_vec(),
        ),
+
        "remote" => term::run_command_args::<rad_remote::Options, _>(
+
            rad_remote::HELP,
+
            "Remote",
+
            rad_remote::run,
+
            args.to_vec(),
+
        ),
        _ => {
            let exe = format!("{NAME}-{exe}");
            let status = process::Command::new(exe.clone()).args(args).status();
modified radicle-cli/tests/commands.rs
@@ -640,6 +640,39 @@ fn test_replication_via_seed() {
}

#[test]
+
fn rad_remote() {
+
    let mut environment = Environment::new();
+
    let alice = environment.node("alice");
+
    let bob = environment.node("bob");
+
    let working = environment.tmp().join("working");
+
    let home = alice.home.clone();
+
    // Setup a test repository.
+
    fixtures::repository(working.join("alice"));
+

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

+
    let mut alice = alice.spawn(Config::default());
+
    alice
+
        .handle
+
        .track_node(bob.id, Some("bob".to_owned()))
+
        .unwrap();
+

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

+
#[test]
fn rad_workflow() {
    let mut environment = Environment::new();
    let alice = environment.node("alice");