From 0e6fae5a037dcef2f0a29ae8739e0e234ffc8af8 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 26 Apr 2023 11:34:28 +0100 Subject: [PATCH] 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 X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/tests/commands.rs | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/radicle-cli/tests/commands.rs b/radicle-cli/tests/commands.rs index 454b2fd7..735b81a4 100644 --- a/radicle-cli/tests/commands.rs +++ b/radicle-cli/tests/commands.rs @@ -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);