Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toblux committed Mar 17, 2024
1 parent 700c282 commit 3731d17
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/clamav_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,19 @@ mod tokio_tests {
assert_eq!(&response, clamav_client::PONG);
}

#[tokio::test]
#[cfg(unix)]
async fn async_tokio_get_version_socket() {
let err_msg = format!(
"Could not get ClamAV version via Unix socket at {}",
CLAMD_HOST_SOCKET.socket_path
);
let response = clamav_client::tokio::get_version(CLAMD_HOST_SOCKET)
.await
.expect(&err_msg);
assert!(&response.starts_with(b"ClamAV"));
}

#[tokio::test]
#[cfg(unix)]
async fn async_tokio_scan_socket_infected_file() {
Expand Down Expand Up @@ -267,6 +280,18 @@ mod tokio_tests {
assert_eq!(&response, clamav_client::PONG);
}

#[tokio::test]
async fn async_tokio_get_version_tcp() {
let err_msg = format!(
"Could not get ClamAV version via TCP at {}",
CLAMD_HOST_TCP.host_address
);
let response = clamav_client::tokio::get_version(CLAMD_HOST_TCP)
.await
.expect(&err_msg);
assert!(&response.starts_with(b"ClamAV"));
}

#[tokio::test]
async fn async_tokio_scan_tcp_infected_file() {
let err_msg = format!(
Expand Down Expand Up @@ -466,6 +491,19 @@ mod async_std_tests {
assert_eq!(&response, clamav_client::PONG);
}

#[async_std::test]
#[cfg(unix)]
async fn async_std_get_version_socket() {
let err_msg = format!(
"Could not get ClamAV version via Unix socket at {}",
CLAMD_HOST_SOCKET.socket_path
);
let response = clamav_client::async_std::get_version(CLAMD_HOST_SOCKET)
.await
.expect(&err_msg);
assert!(&response.starts_with(b"ClamAV"));
}

#[async_std::test]
#[cfg(unix)]
async fn async_std_scan_socket_infected_file() {
Expand Down Expand Up @@ -538,6 +576,18 @@ mod async_std_tests {
assert_eq!(&response, clamav_client::PONG);
}

#[async_std::test]
async fn async_std_get_version_tcp() {
let err_msg = format!(
"Could not get ClamAV version via TCP at {}",
CLAMD_HOST_TCP.host_address
);
let response = clamav_client::async_std::get_version(CLAMD_HOST_TCP)
.await
.expect(&err_msg);
assert!(&response.starts_with(b"ClamAV"));
}

#[async_std::test]
async fn async_std_scan_tcp_infected_file() {
let err_msg = format!(
Expand Down

0 comments on commit 3731d17

Please sign in to comment.