use crate::science::compose::{Intent, draft};
use crate::science::tests::candidate;
use crate::workdiff::Change;
#[test]
fn the_judge_goal_carries_every_candidates_exact_refs() {
let rows = vec![
candidate("at-1", Some("alpha")),
candidate("at-2", Some("beta")),
];
let d = draft(&Intent::Judge, &rows).expect("two candidates compose");
assert!(d.new_conversation);
assert!(
d.text.starts_with("Judge the candidate attempts"),
"{}",
d.text
);
assert!(
d.text
.contains("Project proj, ball bl-1, target work/bl-1 at aaaa1111bbbb2222"),
"{}",
d.text
);
assert!(
d.text.contains(
"- candidate at-1: branch attempt/at-1 at at-100tip, forked from base basebase1234beef"
),
"{}",
d.text
);
assert!(
d.text
.contains("- candidate at-2: branch attempt/at-2 at at-200tip"),
"{}",
d.text
);
}
#[test]
fn the_synthesize_goal_is_the_same_refs_under_a_different_ask() {
let rows = vec![candidate("at-1", None)];
let d = draft(&Intent::Synthesize, &rows).expect("a candidate composes");
assert!(d.new_conversation);
assert!(d.text.starts_with("Synthesize one result"), "{}", d.text);
assert!(
d.text.contains("- candidate at-1: branch attempt/at-1"),
"{}",
d.text
);
}
#[test]
fn an_unknown_base_is_said_and_the_claim_row_is_not_cited() {
let mut fanned = candidate("at-1", None);
fanned.base = None;
let mut claim = candidate("ignored", None);
claim.diff.handle = None;
let d = draft(&Intent::Judge, &[claim, fanned]).expect("one candidate composes");
assert!(d.text.contains("forked from base unknown"), "{}", d.text);
assert!(!d.text.contains("ignored"), "{}", d.text);
}
#[test]
fn nothing_to_cite_composes_nothing() {
assert_eq!(draft(&Intent::Judge, &[]), None);
let mut unresolved = candidate("at-1", None);
unresolved.diff.change = Change::Unreadable;
assert_eq!(draft(&Intent::Judge, &[unresolved.clone()]), None);
assert_eq!(draft(&Intent::Synthesize, &[unresolved]), None);
}
#[test]
fn deliver_awaits_a_summary_and_retire_is_complete() {
let rows = vec![candidate("at-1", None)];
let deliver = draft(
&Intent::Deliver {
handle: "at-1".to_owned(),
},
&rows,
)
.expect("deliver composes");
assert_eq!(deliver.text, "/deliver at-1 ");
assert!(!deliver.new_conversation);
let retire = draft(
&Intent::Retire {
handle: "at-1".to_owned(),
},
&rows,
)
.expect("retire composes");
assert_eq!(retire.text, "/retire at-1");
assert!(!retire.new_conversation);
}