Compare commits
2 Commits
cc18b1cfe6
...
9b9b8d0b13
| Author | SHA1 | Date |
|---|---|---|
|
|
9b9b8d0b13 | |
|
|
627a132e53 |
|
|
@ -6,6 +6,10 @@ edition = "2021"
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
|
[profile.test]
|
||||||
|
debug = false
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0.93"
|
anyhow = "1.0.93"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,27 @@ pub fn setup_logger() -> Result<(), crate::options::structs::CustomError> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod logger_tests {
|
mod logger_tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
// #[test]
|
||||||
|
// fn setting_up_logger() {
|
||||||
|
// assert!(setup_logger().is_ok());
|
||||||
|
// }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn setting_up_logger() {
|
fn setting_up_logger() {
|
||||||
assert!(setup_logger().is_ok());
|
Builder::new()
|
||||||
|
.format(move |buf, record| {
|
||||||
|
writeln!(
|
||||||
|
buf,
|
||||||
|
"|{}| {} [{}] - {}",
|
||||||
|
get_container_id().unwrap_or("NODE".to_string()).trim(),
|
||||||
|
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
||||||
|
record.level(),
|
||||||
|
record.args(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.filter(None, LevelFilter::Info)
|
||||||
|
.target(env_logger::Target::Stdout)
|
||||||
|
.is_test(true)
|
||||||
|
.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,7 @@ pub async fn start_process(name: &str, path: &str) -> Result<(), CustomError> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod process_unittests {
|
mod process_unittests {
|
||||||
|
use std::io::Write;
|
||||||
use super::*;
|
use super::*;
|
||||||
// 1 full cycle - start -> restart -> stop
|
// 1 full cycle - start -> restart -> stop
|
||||||
// 2 full cycle - start -> freeze -> unfreze -> stop
|
// 2 full cycle - start -> freeze -> unfreze -> stop
|
||||||
|
|
@ -233,6 +234,7 @@ 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 _ = std::io::stdout().write_all(b"");
|
||||||
let res1 = start_process("temp-process", "./temp-process").await;
|
let res1 = start_process("temp-process", "./temp-process").await;
|
||||||
assert!(res1.is_ok());
|
assert!(res1.is_ok());
|
||||||
let res2 =
|
let res2 =
|
||||||
|
|
@ -249,6 +251,7 @@ mod process_unittests {
|
||||||
}
|
}
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn is_active_check() {
|
async fn is_active_check() {
|
||||||
|
// let _ = std::io::stdout().write_all(b"");
|
||||||
let res1 = start_process("tmp-prc", "./tests/examples/tmp-prc").await;
|
let res1 = start_process("tmp-prc", "./tests/examples/tmp-prc").await;
|
||||||
assert!(res1.is_ok());
|
assert!(res1.is_ok());
|
||||||
assert!(is_active("tmp-prc").await);
|
assert!(is_active("tmp-prc").await);
|
||||||
|
|
@ -260,6 +263,7 @@ mod process_unittests {
|
||||||
}
|
}
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn is_frozen_check() {
|
async fn is_frozen_check() {
|
||||||
|
// let _ = std::io::stdout().write_all(b"");
|
||||||
let res1 = start_process("freeze-check", "./tests/examples/freeze-check").await;
|
let res1 = start_process("freeze-check", "./tests/examples/freeze-check").await;
|
||||||
assert!(res1.is_ok());
|
assert!(res1.is_ok());
|
||||||
assert!(!is_frozen("freeze-check").await);
|
assert!(!is_frozen("freeze-check").await);
|
||||||
|
|
|
||||||
BIN
temp-process
BIN
temp-process
Binary file not shown.
Loading…
Reference in New Issue