use super::super::delete;
use crate::template::{GitRunner, RealGit};
use crate::workspace::{self, agent_ref, config_ref, proposal::proposal_ref, repo_git};
const REVIEWER: &str = "20260101-a1-20260102-r2";
#[test]
fn deleting_a_reviewer_reaps_its_proposal_and_its_read_mark() {
let (_h, ws) = workspace::fixture::workspace();
workspace::fixture::spawn_root(&ws, "20260101-a1");
workspace::fixture::spawn_agent(&ws, REVIEWER, &agent_ref("20260101-a1"));
let git = RealGit::new();
let repo = repo_git(&ws);
let tip = git
.run_capture(&repo, &["rev-parse", &config_ref("default")])
.unwrap();
let tip = tip.trim();
workspace::proposal::write_read_mark(&repo, REVIEWER, tip, &git).unwrap();
git.run(&repo, &["branch", &proposal_ref(REVIEWER), tip])
.unwrap();
delete(&ws, REVIEWER, false, false, &git).unwrap();
let refs = git
.run_capture(&repo, &["for-each-ref", "--format=%(refname)"])
.unwrap();
assert!(
!refs.contains(REVIEWER),
"no ref of any kind still names the reviewer: {refs}"
);
assert!(
refs.contains(&config_ref("default")),
"and the lineage it read is untouched: {refs}"
);
}
#[test]
fn deleting_a_reviewer_that_proposed_nothing_is_the_same_act() {
let (_h, ws) = workspace::fixture::workspace();
workspace::fixture::spawn_root(&ws, "20260101-a1");
let report = delete(&ws, "20260101-a1", false, false, &RealGit::new()).unwrap();
assert!(report.removed);
assert!(!workspace::agent_exists(
&ws,
"20260101-a1",
&RealGit::new()
));
}