use crate::fork::{Choices, choices, roles_at};
use crate::git_tree::tests::fixture::Fixture;
use crate::test_support::TEMPLATE_PROVIDERS;
use std::path::Path;
const CONV: &str = "20260803T090000Z-aaaa";
fn workspace() -> Fixture {
let fx = Fixture::new();
fx.commit_other("providers.yaml", TEMPLATE_PROVIDERS);
fx.build_agent(CONV, "walk the rail");
fx
}
#[test]
fn the_points_are_here_and_every_config_branch() {
let fx = workspace();
fx.config_off("strict", "config/default");
let out = choices(&fx.path, &format!("agents/{CONV}"), Path::new("/no-pool"));
let labels: Vec<&str> = out.points.iter().map(|p| p.label.as_str()).collect();
assert_eq!(labels, vec!["here", "default", "strict"]);
let refs: Vec<&str> = out.points.iter().map(|p| p.refspec.as_str()).collect();
assert_eq!(
refs,
vec![
format!("agents/{CONV}").as_str(),
"config/default",
"config/strict"
]
);
}
#[test]
fn every_point_names_the_model_its_config_binds() {
let fx = workspace();
let out = choices(&fx.path, &format!("agents/{CONV}"), Path::new("/no-pool"));
let here = out
.point(&format!("agents/{CONV}"))
.expect("here is offered");
let named: Vec<(String, String)> = here
.roles
.iter()
.map(|r| (r.role.clone(), r.model.clone()))
.collect();
assert_eq!(
named,
vec![
("worker".to_owned(), "claude-sonnet-5".to_owned()),
("compactor".to_owned(), "claude-haiku-4-5".to_owned()),
]
);
assert!(out.fireable());
}
#[test]
fn a_ref_that_declares_nothing_offers_nothing() {
let fx = Fixture::new();
fx.orphan_agent("stray");
assert!(roles_at(&fx.path, "agents/stray").is_empty());
assert!(roles_at(&fx.path, "config/default").is_empty());
let out = choices(&fx.path, "config/default", Path::new("/no-pool"));
assert!(!out.fireable(), "nothing to fire ⇒ no seat paints");
assert!(out.point("config/default").is_some(), "the ref still shows");
assert!(out.point("nowhere").is_none());
}
#[test]
fn nothing_offered_is_nothing_to_fire() {
let empty = Choices::default();
assert!(!empty.fireable());
assert!(empty.point("here").is_none());
}