cli: Add tests for `rad publish`
This commit is contained in:
parent
45a2c05a9e
commit
112c940d81
|
|
@ -0,0 +1,40 @@
|
|||
Given a private repo `rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu` belonging to Alice,
|
||||
Bob tries to clone it, and even though he's connected to Alice, it fails.
|
||||
|
||||
``` ~bob
|
||||
$ rad track rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu
|
||||
✓ Tracking policy updated for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu with scope 'trusted'
|
||||
$ rad ls
|
||||
```
|
||||
``` ~bob (fail)
|
||||
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch --seed z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi --timeout 1
|
||||
✗ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi.. error: connection reset
|
||||
✗ Error: repository fetch from 1 seed(s) failed
|
||||
```
|
||||
|
||||
She allows Bob to view the repository. And when she syncs, one node (Bob) gets
|
||||
the refs.
|
||||
|
||||
``` ~alice
|
||||
$ rad id edit --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
|
||||
e98cd6a0a3e94837b382e59e02b3ea83991a8244
|
||||
$ rad id accept e98cd6a0a3e94837b382e59e02b3ea83991a8244 -q
|
||||
$ rad id commit e98cd6a0a3e94837b382e59e02b3ea83991a8244 -q
|
||||
c568f8aac97db40a5e63e1261872bfbd9a3a61e4
|
||||
$ rad sync --announce --timeout 3
|
||||
✓ Synced with 1 node(s)
|
||||
```
|
||||
|
||||
Bob can now fetch the private repo:
|
||||
|
||||
``` ~bob
|
||||
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch
|
||||
✓ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi..
|
||||
✓ Fetched repository from 1 seed(s)
|
||||
$ rad ls --private
|
||||
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Visibility Head Description │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu private f2de534 radicle heartwood protocol & stack │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
Alice initializes a *private* repo.
|
||||
Alice can initialize a *private* repo using the `--private` flag.
|
||||
|
||||
``` ~alice
|
||||
```
|
||||
$ rad init --name heartwood --description "radicle heartwood protocol & stack" --no-confirm --private
|
||||
|
||||
Initializing private radicle 👾 project in .
|
||||
|
|
@ -16,43 +16,3 @@ This repository will only be visible to you, and to peers you explicitly allow.
|
|||
To make it public, run `rad publish`.
|
||||
To push changes, run `git push`.
|
||||
```
|
||||
|
||||
Bob tries to clone it, and even though he's connected to Alice, it fails.
|
||||
|
||||
``` ~bob
|
||||
$ rad track rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu
|
||||
✓ Tracking policy updated for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu with scope 'trusted'
|
||||
$ rad ls
|
||||
```
|
||||
``` ~bob (fail)
|
||||
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch --seed z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi --timeout 1
|
||||
✗ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi.. error: connection reset
|
||||
✗ Error: repository fetch from 1 seed(s) failed
|
||||
```
|
||||
|
||||
She allows Bob to view the repository. And when she syncs, one node (Bob) gets
|
||||
the refs.
|
||||
|
||||
``` ~alice
|
||||
$ rad id edit --allow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
|
||||
e98cd6a0a3e94837b382e59e02b3ea83991a8244
|
||||
$ rad id accept e98cd6a0a3e94837b382e59e02b3ea83991a8244 -q
|
||||
$ rad id commit e98cd6a0a3e94837b382e59e02b3ea83991a8244 -q
|
||||
c568f8aac97db40a5e63e1261872bfbd9a3a61e4
|
||||
$ rad sync --announce --timeout 3
|
||||
✓ Synced with 1 node(s)
|
||||
```
|
||||
|
||||
Bob can now fetch the private repo:
|
||||
|
||||
``` ~bob
|
||||
$ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch
|
||||
✓ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi..
|
||||
✓ Fetched repository from 1 seed(s)
|
||||
$ rad ls --private
|
||||
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Visibility Head Description │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu private f2de534 radicle heartwood protocol & stack │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
Let's say we have a private repo. To make it public, we use the `publish` command:
|
||||
|
||||
```
|
||||
$ rad inspect --visibility
|
||||
private
|
||||
$ rad publish
|
||||
✓ Repository is now public
|
||||
! Warning: Your node is not running. Start your node with `rad node start` to announce your repository to the network
|
||||
$ rad inspect --visibility
|
||||
public
|
||||
```
|
||||
|
||||
If we try to publish again, we get an error:
|
||||
|
||||
``` (fail)
|
||||
$ rad publish
|
||||
✗ Error: repository is already public
|
||||
✗ Hint: to announce the repository to the network, run `rad sync --inventory`
|
||||
```
|
||||
|
|
@ -34,14 +34,15 @@ Usage
|
|||
|
||||
Options
|
||||
|
||||
--rid Return the repository identifier (RID)
|
||||
--payload Inspect the repository's identity payload
|
||||
--refs Inspect the repository's refs on the local device
|
||||
--identity Inspect the identity document
|
||||
--delegates Inspect the repository's delegates
|
||||
--policy Inspect the repository's tracking policy
|
||||
--history Show the history of the repository identity document
|
||||
--help Print help
|
||||
--rid Return the repository identifier (RID)
|
||||
--payload Inspect the repository's identity payload
|
||||
--refs Inspect the repository's refs on the local device
|
||||
--identity Inspect the identity document
|
||||
--visibility Inspect the repository's visibility
|
||||
--delegates Inspect the repository's delegates
|
||||
--policy Inspect the repository's tracking policy
|
||||
--history Show the history of the repository identity document
|
||||
--help Print help
|
||||
"#,
|
||||
};
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ pub enum Target {
|
|||
Payload,
|
||||
Delegates,
|
||||
Identity,
|
||||
Visibility,
|
||||
Policy,
|
||||
History,
|
||||
#[default]
|
||||
|
|
@ -97,6 +99,9 @@ impl Args for Options {
|
|||
Long("rid") => {
|
||||
target = Target::RepoId;
|
||||
}
|
||||
Long("visibility") => {
|
||||
target = Target::Visibility;
|
||||
}
|
||||
Value(val) if rid.is_none() => {
|
||||
let val = val.to_string_lossy();
|
||||
|
||||
|
|
@ -175,9 +180,8 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
Target::Delegates => {
|
||||
let (doc, _) = Doc::<_>::load(signer.public_key(), &repo)?;
|
||||
let aliases = profile.aliases();
|
||||
for did in doc.delegates {
|
||||
for did in project.doc.delegates {
|
||||
if let Some(alias) = aliases.alias(&did) {
|
||||
println!(
|
||||
"{} {}",
|
||||
|
|
@ -189,6 +193,9 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Target::Visibility => {
|
||||
println!("{}", term::format::visibility(&project.doc.visibility));
|
||||
}
|
||||
Target::History => {
|
||||
let head = Doc::<Untrusted>::head(signer.public_key(), &repo)?;
|
||||
let history = repo.revwalk(head)?;
|
||||
|
|
|
|||
|
|
@ -1207,6 +1207,23 @@ fn rad_patch_pull_update() {
|
|||
|
||||
#[test]
|
||||
fn rad_init_private() {
|
||||
let mut environment = Environment::new();
|
||||
let alice = environment.node(Config::test(Alias::new("alice")));
|
||||
let working = environment.tmp().join("working");
|
||||
|
||||
fixtures::repository(working.join("alice"));
|
||||
|
||||
test(
|
||||
"examples/rad-init-private.md",
|
||||
working.join("alice"),
|
||||
Some(&alice.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_init_private_clone() {
|
||||
logger::init(log::Level::Debug);
|
||||
|
||||
let mut environment = Environment::new();
|
||||
|
|
@ -1219,9 +1236,17 @@ fn rad_init_private() {
|
|||
let alice = alice.spawn();
|
||||
let mut bob = bob.spawn();
|
||||
|
||||
test(
|
||||
"examples/rad-init-private.md",
|
||||
working.join("alice"),
|
||||
Some(&alice.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
bob.connect(&alice).converge([&alice]);
|
||||
|
||||
formula(&environment.tmp(), "examples/rad-init-private.md")
|
||||
formula(&environment.tmp(), "examples/rad-init-private-clone.md")
|
||||
.unwrap()
|
||||
.home(
|
||||
"alice",
|
||||
|
|
@ -1237,6 +1262,31 @@ fn rad_init_private() {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_publish() {
|
||||
let mut environment = Environment::new();
|
||||
let alice = environment.node(Config::test(Alias::new("alice")));
|
||||
let working = environment.tmp().join("working");
|
||||
|
||||
fixtures::repository(working.join("alice"));
|
||||
|
||||
test(
|
||||
"examples/rad-init-private.md",
|
||||
working.join("alice"),
|
||||
Some(&alice.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
test(
|
||||
"examples/rad-publish.md",
|
||||
working.join("alice"),
|
||||
Some(&alice.home),
|
||||
[],
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn framework_home() {
|
||||
logger::init(log::Level::Debug);
|
||||
|
|
|
|||
Loading…
Reference in New Issue