use std::path::PathBuf;
use super::{VoiceConfig, loader::VoiceLoader, principles::principles_addendum, types::*};
#[test]
fn full_pipeline_with_duetto_voice() {
let loader = VoiceLoader::new();
let pkg = loader.load("duetto").expect("bundled duetto must load");
let addendum = pkg.effective_addendum();
assert!(
!addendum.is_empty(),
"duetto effective_addendum must be non-empty"
);
let vc = VoiceConfig {
principles: Some(principles_addendum().to_string()),
voice_addendum: Some(addendum.clone()),
voice_name: Some("duetto".to_string()),
};
let combined = vc.combined_addendum();
assert!(
combined.contains("Review principles") || combined.contains("BLOCK"),
"combined must contain principles content"
);
assert!(
combined.contains("correctness"),
"combined must contain duetto correctness guidance"
);
let p_pos = combined.find("BLOCK").unwrap_or(usize::MAX);
assert!(
p_pos != usize::MAX,
"BLOCK should appear (from principles or duetto)"
);
assert!(
vc.has_any_addendum(),
"full config must report has_any_addendum=true"
);
}
#[test]
fn bundled_duetto_matches_external_when_present() {
let external_path: PathBuf = {
let Some(cfg) = dirs::config_dir() else {
return;
};
cfg.join("trusty-review")
.join("voices")
.join("duetto")
.join("voice.toml")
};
if !external_path.exists() {
return;
}
let loader_bundled = VoiceLoader::bundled_only();
let bundled = loader_bundled
.load("duetto")
.expect("bundled duetto must load via bundled_only");
let external_content =
std::fs::read_to_string(&external_path).expect("external file must be readable");
let external: VoicePackage =
toml::from_str(&external_content).expect("external voice.toml must parse");
assert_eq!(
bundled.meta.name, external.meta.name,
"bundled and external meta.name must match"
);
assert_eq!(
bundled.meta.version, external.meta.version,
"bundled and external meta.version must match"
);
let b_prefix = bundled
.voice
.system_addendum
.chars()
.take(100)
.collect::<String>();
let e_prefix = external
.voice
.system_addendum
.chars()
.take(100)
.collect::<String>();
assert_eq!(
b_prefix, e_prefix,
"bundled and external system_addendum prefix must match"
);
}