Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
cli/tests: Add test for `rad clone --scope`
Defelo committed 1 month ago
commit 281f92e9ff35d5956a19caa54b629af3a226fc68
parent eea3617
2 files changed +83 -0
added crates/radicle-cli/examples/rad-clone-scope.md
@@ -0,0 +1,63 @@
+
By default `rad clone` should add a seeding policy with the `followed` scope:
+

+
```
+
$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'followed'
+
✓ Creating checkout in ./heartwood..
+
✓ Repository successfully cloned under [..]/heartwood/
+
╭────────────────────────────────────╮
+
│ heartwood                          │
+
│ Radicle Heartwood Protocol & Stack │
+
│ 0 issues · 0 patches               │
+
╰────────────────────────────────────╯
+
Run `cd ./heartwood` to go to the repository directory.
+
$ rad seed
+
╭───────────────────────────────────────────────────────────────────╮
+
│ Repository                          Name        Policy   Scope    │
+
├───────────────────────────────────────────────────────────────────┤
+
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   heartwood   allow    followed │
+
╰───────────────────────────────────────────────────────────────────╯
+
$ rm -rf heartwood
+
```
+

+
Specifying a different scope explicitly should update the policy:
+

+
```
+
$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope all
+
✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all'
+
✓ Creating checkout in ./heartwood..
+
✓ Repository successfully cloned under [..]/heartwood/
+
╭────────────────────────────────────╮
+
│ heartwood                          │
+
│ Radicle Heartwood Protocol & Stack │
+
│ 0 issues · 0 patches               │
+
╰────────────────────────────────────╯
+
Run `cd ./heartwood` to go to the repository directory.
+
$ rad seed
+
╭────────────────────────────────────────────────────────────────╮
+
│ Repository                          Name        Policy   Scope │
+
├────────────────────────────────────────────────────────────────┤
+
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   heartwood   allow    all   │
+
╰────────────────────────────────────────────────────────────────╯
+
$ rm -rf heartwood
+
```
+

+
Running `rad clone` again without an explicit scope parameter should not change the existing policy:
+

+
```
+
$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Creating checkout in ./heartwood..
+
✓ Repository successfully cloned under [..]/heartwood/
+
╭────────────────────────────────────╮
+
│ heartwood                          │
+
│ Radicle Heartwood Protocol & Stack │
+
│ 0 issues · 0 patches               │
+
╰────────────────────────────────────╯
+
Run `cd ./heartwood` to go to the repository directory.
+
$ rad seed
+
╭────────────────────────────────────────────────────────────────╮
+
│ Repository                          Name        Policy   Scope │
+
├────────────────────────────────────────────────────────────────┤
+
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji   heartwood   allow    all   │
+
╰────────────────────────────────────────────────────────────────╯
+
```
modified crates/radicle-cli/tests/commands/clone.rs
@@ -295,3 +295,23 @@ fn test_clone_without_seeds() {
        .rad("inspect", &[], working.join("heartwood").as_path())
        .unwrap();
}
+

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

+
    let rid = alice.project("heartwood", "Radicle Heartwood Protocol & Stack");
+

+
    let mut alice = alice.spawn();
+
    alice.handle.unseed(rid).unwrap();
+

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