cli/tests: Add test for `rad clone --scope`

This commit is contained in:
Defelo 2026-03-13 22:26:41 +01:00 committed by Fintan Halpenny
parent eea3617781
commit 281f92e9ff
2 changed files with 83 additions and 0 deletions

View File

@ -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 │
╰────────────────────────────────────────────────────────────────╯
```

View File

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