tests: add radicle command test for the rad remote

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Vincenzo Palazzo 2023-04-20 21:09:39 +02:00 committed by Alexis Sellier
parent d55861572d
commit 5a4d0fff3f
No known key found for this signature in database
5 changed files with 79 additions and 4 deletions

View File

@ -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
```

View File

@ -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"]

View File

@ -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(())
}

View File

@ -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();

View File

@ -639,6 +639,39 @@ fn test_replication_via_seed() {
.unwrap();
}
#[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();