synchronizer 0.1.1

Little daemon service to synchronize all your containers across devices - Keep Your Cluster in Harmony
Documentation
mod checks;
mod error;
mod logic;
#[cfg(test)]
mod tests {
    use std::net::Ipv4Addr;
    use crate::{checks::Dependencies, error::SyncError, logic::ip};

     

    #[test]
    fn test_ip_valid() {
        assert_eq!(ip("127.0.0.1").unwrap(), Ipv4Addr::new(127, 0, 0, 1));
        assert_eq!(ip("192.168.1.1").unwrap(), Ipv4Addr::new(192, 168, 1, 1));
        assert_eq!(ip("8.8.8.8").unwrap(), Ipv4Addr::new(8, 8, 8, 8));
    }

    #[test]
    fn test_ip_invalid() {
        match ip("127.0.1").unwrap_err() {
            SyncError::InvalidIPv4 => (),
            _ => panic!("Expected InvalidIPv4 error"),
        };

        match ip("127.0.0.256").unwrap_err() {
            SyncError::InvalidIPv4 => (),
            _ => panic!("Expected InvalidIPv4 error"),
        };

        match ip("127.0.0.a").unwrap_err() {
            SyncError::InvalidIPv4 => (),
            _ => panic!("Expected InvalidIPv4 error"),
        };
    }

    #[test]
    #[ignore]
    fn test_dependencies_installed_both() {
        // Requires both Docker and Podman installed.
        match Dependencies::new().installed().unwrap_err() {
            crate::checks::ChecksError::BothInstalled => (),
            _ => panic!("Expected BothInstalled error"),
        };
    }

    #[test]
    #[ignore]
    fn test_dependencies_installed_docker_missing() {
        // Requires Docker NOT installed and Podman installed.
        match Dependencies::new().installed().unwrap_err() {
            crate::checks::ChecksError::NotInstalled(crate::logic::Backend::Docker) => (),
            _ => panic!("Expected Docker NotInstalled error"),
        };
    }

    #[test]
    #[ignore]
    fn test_dependencies_installed_podman_missing() {
        // Requires Podman NOT installed and Docker installed.
        match Dependencies::new().installed().unwrap_err() {
            crate::checks::ChecksError::NotInstalled(crate::logic::Backend::Podman) => (),
            _ => panic!("Expected Podman NotInstalled error"),
        };
    }

    #[test]
    #[ignore]
    fn test_dependencies_installed_none() {
        // Requires Neither Docker or Podman installed.
        match Dependencies::new().installed().unwrap_err() {
            crate::checks::ChecksError::NotInstalled(_) => (),
            _ => panic!("Expected NotInstalled error"),
        };
    }

    #[test]
    #[should_panic]
    fn test_dependencies_container_exists() {
        // Requires /app directory to exist
        assert_eq!(Dependencies::new().container().unwrap(), true);
    }

    #[test]
    #[ignore]
    fn test_dependencies_container_not_exists() {
        // Requires /app directory to not exist
        match Dependencies::new().container().unwrap_err() {
            crate::checks::ChecksError::NotInContainer => (),
            _ => panic!("Expected NotInContainer error"),
        };
    }
}