use anyhow::Result;
mod common;
#[test]
fn test_list_templates() -> Result<()> {
let templates = ferrisup::template_manager::list_templates()?;
assert!(!templates.is_empty(), "Template list should not be empty");
let expected_templates = ["minimal", "library", "server"];
for template in expected_templates.iter() {
assert!(
templates.iter().any(|(name, _)| name == template),
"Expected template '{}' not found",
template
);
}
for (name, description) in &templates {
assert!(!description.is_empty(), "Template '{}' is missing a description", name);
}
Ok(())
}
#[test]
fn test_get_template() -> Result<()> {
let templates_to_test = ["minimal", "library", "server"];
for template in templates_to_test.iter() {
let template_content = ferrisup::template_manager::get_template(template)?;
assert!(!template_content.is_empty(), "Template content should not be empty");
assert_eq!(template_content, *template, "Template content should match template name");
}
Ok(())
}
#[test]
fn test_get_all_templates() -> Result<()> {
let templates = ferrisup::template_manager::get_all_templates()?;
assert!(!templates.is_empty(), "Template list should not be empty");
let expected_templates = ["minimal", "library", "server"];
for template in expected_templates.iter() {
assert!(
templates.contains(&template.to_string()),
"Expected template '{}' not found",
template
);
}
Ok(())
}
#[test]
fn test_template_validation() -> Result<()> {
let result = ferrisup::template_manager::get_template("non_existent_template");
assert!(result.is_ok(), "Should fallback to minimal template");
assert_eq!(result.as_ref().expect("Should contain a template name"), "minimal", "Should fallback to minimal template");
Ok(())
}