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() {
match Dependencies::new().installed().unwrap_err() {
crate::checks::ChecksError::BothInstalled => (),
_ => panic!("Expected BothInstalled error"),
};
}
#[test]
#[ignore]
fn test_dependencies_installed_docker_missing() {
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() {
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() {
match Dependencies::new().installed().unwrap_err() {
crate::checks::ChecksError::NotInstalled(_) => (),
_ => panic!("Expected NotInstalled error"),
};
}
#[test]
#[should_panic]
fn test_dependencies_container_exists() {
assert_eq!(Dependencies::new().container().unwrap(), true);
}
#[test]
#[ignore]
fn test_dependencies_container_not_exists() {
match Dependencies::new().container().unwrap_err() {
crate::checks::ChecksError::NotInContainer => (),
_ => panic!("Expected NotInContainer error"),
};
}
}