Compare commits

..

3 Commits

Author SHA1 Message Date
prplV 1884469c9e prcs unittests fix --no-abs-path 2024-11-26 17:46:03 +03:00
prplV 406b199b09 exec files needed in tests added 2024-11-26 17:42:52 +03:00
prplV 150bb87a41 files unit tests fix 2024-11-26 17:40:11 +03:00
4 changed files with 13 additions and 8 deletions

View File

@ -159,22 +159,22 @@ mod files_unittests {
use super::*; use super::*;
#[tokio::test] #[tokio::test]
async fn try_to_create_watcher() { async fn try_to_create_watcher() {
let res = create_watcher("dep-file", "/home/user/monitor/runner-rs/tests/examples/").await; let res = create_watcher("dep-file", "./tests/examples/").await;
assert!(res.is_ok()); assert!(res.is_ok());
} }
#[tokio::test] #[tokio::test]
async fn try_to_create_invalid_watcher() { async fn try_to_create_invalid_watcher() {
let res = create_watcher("invalid-file", "/path/to/the/hell").await; let res = create_watcher("invalid-file", "/path/to/the/no/dir").await;
assert!(res.is_err()); assert!(res.is_err());
} }
#[tokio::test] #[tokio::test]
async fn check_existing_file() { async fn check_existing_file() {
let res = check_file("dep-file", "/home/user/monitor/runner-rs/tests/examples/").await; let res = check_file("dep-file", "./tests/examples/").await;
assert!(res.is_ok()); assert!(res.is_ok());
} }
#[tokio::test] #[tokio::test]
async fn check_non_existing_file() { async fn check_non_existing_file() {
let res = check_file("invalid-file", "/path/to/the/hell").await; let res = check_file("invalid-file", "/path/to/the/no/dir").await;
assert!(res.is_err()); assert!(res.is_err());
} }
} }

View File

@ -233,10 +233,10 @@ mod process_unittests {
// rewrite, its a pipe // rewrite, its a pipe
#[tokio::test] #[tokio::test]
async fn full_cycle_with_restart() { async fn full_cycle_with_restart() {
let res1 = start_process("temp-process", "/home/user/monitor/runner-rs/temp-process").await; let res1 = start_process("temp-process", "./temp-process").await;
assert!(res1.is_ok()); assert!(res1.is_ok());
let res2 = let res2 =
restart_process("temp-process", "/home/user/monitor/runner-rs/temp-process").await; restart_process("temp-process", "./temp-process").await;
assert!(res2.is_ok()); assert!(res2.is_ok());
let _ = terminate_process("temp-process").await; let _ = terminate_process("temp-process").await;
let res3 = is_active("temp-process").await; let res3 = is_active("temp-process").await;
@ -249,7 +249,10 @@ mod process_unittests {
} }
#[tokio::test] #[tokio::test]
async fn is_active_check() { async fn is_active_check() {
assert!(is_active("systemd").await); let res1 = start_process("tmp-prc", "./tests/examples/tmp-prc").await;
assert!(res1.is_ok());
assert!(is_active("tmp-prc").await);
let _ = terminate_process("tmp-prc").await;
} }
#[tokio::test] #[tokio::test]
async fn isnt_active_check() { async fn isnt_active_check() {
@ -257,7 +260,9 @@ mod process_unittests {
} }
#[tokio::test] #[tokio::test]
async fn is_frozen_check() { async fn is_frozen_check() {
assert!(!is_frozen("systemd").await); let res1 = start_process("freeze-check", "./tests/examples/freeze-check").await;
assert!(res1.is_ok());
assert!(!is_frozen("freeze-check").await);
} }
#[tokio::test] #[tokio::test]
async fn pidof_active_process() { async fn pidof_active_process() {

BIN
tests/examples/freeze-check Executable file

Binary file not shown.

BIN
tests/examples/tmp-prc Executable file

Binary file not shown.