tests: add radicle command test for the rad remote
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
d55861572d
commit
5a4d0fff3f
|
|
@ -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
|
||||||
|
```
|
||||||
|
|
@ -38,6 +38,8 @@ pub mod rad_patch;
|
||||||
pub mod rad_path;
|
pub mod rad_path;
|
||||||
#[path = "commands/push.rs"]
|
#[path = "commands/push.rs"]
|
||||||
pub mod rad_push;
|
pub mod rad_push;
|
||||||
|
#[path = "commands/remote.rs"]
|
||||||
|
pub mod rad_remote;
|
||||||
#[path = "commands/review.rs"]
|
#[path = "commands/review.rs"]
|
||||||
pub mod rad_review;
|
pub mod rad_review;
|
||||||
#[path = "commands/rm.rs"]
|
#[path = "commands/rm.rs"]
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,7 @@ pub fn run(
|
||||||
|
|
||||||
let url = Url::from(id).with_namespace(*pubkey);
|
let url = Url::from(id).with_namespace(*pubkey);
|
||||||
let remote = add_remote(repository, &name, &url)?;
|
let remote = add_remote(repository, &name, &url)?;
|
||||||
term::success!(
|
term::success!("Remote {} added with {url}", remote.name,);
|
||||||
"Remote {} added with {url}",
|
|
||||||
remote.name,
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,6 +337,12 @@ fn run_other(exe: &str, args: &[OsString]) -> Result<(), Option<anyhow::Error>>
|
||||||
rad_web::run,
|
rad_web::run,
|
||||||
args.to_vec(),
|
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 exe = format!("{NAME}-{exe}");
|
||||||
let status = process::Command::new(exe.clone()).args(args).status();
|
let status = process::Command::new(exe.clone()).args(args).status();
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,39 @@ fn test_replication_via_seed() {
|
||||||
.unwrap();
|
.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]
|
#[test]
|
||||||
fn rad_workflow() {
|
fn rad_workflow() {
|
||||||
let mut environment = Environment::new();
|
let mut environment = Environment::new();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue