cli: test the deletion of cobs

Ensure that the deletion of cobs is respected by testing a scenario
where a peer creates and then deletes an issue, while another peer
fetches and also has the issue be present and then removed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
Fintan Halpenny 2023-04-26 11:34:28 +01:00 committed by Alexis Sellier
parent 3bfea69642
commit 0e6fae5a03
No known key found for this signature in database
1 changed files with 47 additions and 0 deletions

View File

@ -571,6 +571,53 @@ fn test_cob_replication() {
assert_eq!(alice_issue.title(), "Something's fishy");
}
#[test]
fn test_cob_deletion() {
let mut environment = Environment::new();
let working = tempfile::tempdir().unwrap();
let mut alice = environment.node("alice");
let bob = environment.node("bob");
let rid = alice.project("heartwood", "");
let mut alice = alice.spawn(Config::default());
let mut bob = bob.spawn(Config::default());
alice.handle.track_repo(rid, Scope::All).unwrap();
bob.handle.track_repo(rid, Scope::All).unwrap();
alice.connect(&bob);
bob.routes_to(&[(rid, alice.id)]);
let alice_repo = alice.storage.repository(rid).unwrap();
let mut alice_issues = radicle::cob::issue::Issues::open(&alice_repo).unwrap();
let issue = alice_issues
.create(
"Something's fishy",
"I don't know what it is",
&[],
&[],
&alice.signer,
)
.unwrap();
let issue_id = issue.id();
log::debug!(target: "test", "Issue {} created", issue_id);
bob.rad("clone", &[rid.to_string().as_str()], working.path())
.unwrap();
let bob_repo = bob.storage.repository(rid).unwrap();
let bob_issues = radicle::cob::issue::Issues::open(&bob_repo).unwrap();
assert!(bob_issues.get(issue_id).unwrap().is_some());
let alice_issues = radicle::cob::issue::Issues::open(&alice_repo).unwrap();
alice_issues.remove(issue_id, &alice.signer).unwrap();
bob.handle.fetch(rid, alice.id).unwrap();
let bob_repo = bob.storage.repository(rid).unwrap();
let bob_issues = radicle::cob::issue::Issues::open(&bob_repo).unwrap();
assert!(bob_issues.get(issue_id).unwrap().is_none());
}
#[test]
fn rad_sync() {
logger::init(log::Level::Debug);