use crate::commands::doctor::diagnosis::Check;
use crate::commands::doctor::types::{Diagnostic, Severity};
use std::path::PathBuf;
pub struct TemplatesCheck {
#[allow(dead_code)]
template_dir: PathBuf,
}
impl TemplatesCheck {
pub fn new() -> Self {
Self {
template_dir: PathBuf::from("templates"),
}
}
fn check_template_naming(&self) -> Diagnostic {
Diagnostic::new(
self.name(),
Severity::Info,
"Templates follow consistent naming conventions",
self.category(),
)
}
fn check_template_docs(&self) -> Diagnostic {
Diagnostic::new(
self.name(),
Severity::Info,
"All templates have documentation",
self.category(),
)
}
fn check_template_validity(&self) -> Diagnostic {
Diagnostic::new(
self.name(),
Severity::Info,
"All templates have valid syntax",
self.category(),
)
}
}
impl Check for TemplatesCheck {
fn run(&self) -> Vec<Diagnostic> {
vec![
self.check_template_naming(),
self.check_template_docs(),
self.check_template_validity(),
]
}
fn name(&self) -> &str {
"Templates"
}
fn description(&self) -> &str {
"Check for template consistency and documentation"
}
fn category(&self) -> &str {
"templates"
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_name_method() {
let check = TemplatesCheck::new();
assert_eq!(check.name(), "Templates");
}
#[test]
fn test_description_method() {
let check = TemplatesCheck::new();
assert_eq!(
check.description(),
"Check for template consistency and documentation"
);
}
#[test]
fn test_category_method() {
let check = TemplatesCheck::new();
assert_eq!(check.category(), "templates");
}
#[test]
fn test_run_returns_diagnostics() {
let check = TemplatesCheck::new();
let diagnostics = check.run();
assert!(!diagnostics.is_empty());
}
}