services unit tests

pull/9/head
prplV 2024-10-30 16:37:12 +03:00
parent 5fa3d2fec8
commit 858323e629
1 changed files with 14 additions and 0 deletions

View File

@ -119,3 +119,17 @@ async fn check_service(hostname: &str, port: &u32) -> Result<(), CustomError> {
Err(_) => Err(CustomError::Fatal),
}
}
#[cfg(test)]
mod service_unittests {
use super::check_service;
#[tokio::test]
async fn check_available_service() {
assert!(check_service("ya.ru", &443).await.is_ok());
}
#[tokio::test]
async fn check_unavailable_service() {
assert!(check_service("unavailable.service", &1111).await.is_err());
}
}