extern crate troupekit_kit as troupekit;
use troupekit::{Agent, KitError};
use troupekit_local::LocalCatalog;
const ID: &str = "smollm2-135m-instruct-q2k";
#[tokio::test]
async fn agent_build_refuses_a_planted_cache_file() {
let dir = tempfile::tempdir().expect("tempdir");
std::env::set_var("TROUPEKIT_MODEL_DIR", dir.path());
let spec = LocalCatalog::builtin().get(ID).expect("catalog row");
let planted = dir.path().join(format!("{ID}-{}.gguf", spec.sha256()));
std::fs::File::create(&planted)
.and_then(|f| f.set_len(spec.bytes()))
.expect("plant a same-size file");
let agent = Agent::new("solo")
.instructions("Answer.")
.model(&format!("local/{ID}"));
let text = match agent.build().await {
Err(err @ KitError::Config { .. }) => err.to_string(),
Err(other) => panic!("expected the not-in-cache Config error, got {other}"),
Ok(_) => panic!("a planted file was loaded as the model"),
};
assert!(text.contains(".download(true)"), "{text}");
}