Skip to main content

ferro_cli/doctor/
registry.rs

1//! Registry of doctor checks.
2
3use super::check::DoctorCheck;
4use super::checks::{
5    CopyDirsDockerignoreCollisionCheck, DatabaseUrlSqliteInProdCheck, DbConnectionCheck,
6    DeployEnvParityCheck, DirtyGitTreeCheck, DockerTemplateDriftCheck,
7    FrontendTypesConventionCheck, GeneratedArtifactsCheck, LocalEnvParityCheck, MigrateGateCheck,
8    MigrationsCheck, ToolchainCheck,
9};
10
11/// Returns the canonical ordered list of checks:
12/// toolchain_match → db_connection → migrations_pending → local_env_parity →
13/// deploy_env_parity → copy_dirs_dockerignore_collision →
14/// docker_template_drift → migrate_gate → generated_artifacts →
15/// database_url_sqlite_in_prod → git_clean_and_pushed → frontend_types_convention.
16pub fn default_checks() -> Vec<Box<dyn DoctorCheck>> {
17    vec![
18        Box::new(ToolchainCheck),
19        Box::new(DbConnectionCheck),
20        Box::new(MigrationsCheck),
21        Box::new(LocalEnvParityCheck),
22        Box::new(DeployEnvParityCheck),
23        Box::new(CopyDirsDockerignoreCollisionCheck),
24        Box::new(DockerTemplateDriftCheck),
25        Box::new(MigrateGateCheck),
26        Box::new(GeneratedArtifactsCheck),
27        Box::new(DatabaseUrlSqliteInProdCheck),
28        Box::new(DirtyGitTreeCheck),
29        Box::new(FrontendTypesConventionCheck),
30    ]
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36
37    #[test]
38    fn default_checks_returns_twelve_in_declared_order() {
39        let checks = default_checks();
40        assert_eq!(checks.len(), 12);
41        let names: Vec<&'static str> = checks.iter().map(|c| c.name()).collect();
42        assert_eq!(
43            names,
44            vec![
45                "toolchain_match",
46                "db_connection",
47                "migrations_pending",
48                "local_env_parity",
49                "deploy_env_parity",
50                "copy_dirs_dockerignore_collision",
51                "docker_template_drift",
52                "migrate_gate",
53                "generated_artifacts",
54                "database_url_sqlite_in_prod",
55                "git_clean_and_pushed",
56                "frontend_types_convention",
57            ]
58        );
59    }
60
61    #[test]
62    fn deploy_category_filter_returns_three() {
63        use crate::doctor::check::CheckCategory;
64        let checks = default_checks();
65        let deploy: Vec<&'static str> = checks
66            .iter()
67            .filter(|c| c.category() == CheckCategory::Deploy)
68            .map(|c| c.name())
69            .collect();
70        assert_eq!(
71            deploy,
72            vec![
73                "copy_dirs_dockerignore_collision",
74                "docker_template_drift",
75                "migrate_gate",
76            ]
77        );
78    }
79}