diff --git a/src/database/database.rs b/src/database/database.rs index 494ed6f..6e6b270 100644 --- a/src/database/database.rs +++ b/src/database/database.rs @@ -32,9 +32,17 @@ pub async fn connectToDB() -> Result { - let error_message = format!("Impossible to connect to the database : {}", e); - let logs = utils::Logs::initLog(None, error_message, None); + let mut logs = utils::Logs::initLog( + None, + format!("Impossible to connect to the database : {}", e), + None + ); utils::Logs::error(logs); + logs = utils::Logs::initLog( + None, + format!("The server can run without the database, but all the informations will be not saved !"), + None); + utils::Logs::warning(logs); Err(e) } } diff --git a/src/main.rs b/src/main.rs index 2cd04e0..1b29e94 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ mod utils; mod server; mod database; mod config; +mod tests; use std::env; diff --git a/src/tests/mod.rs b/src/tests/mod.rs new file mode 100644 index 0000000..cc4fe7a --- /dev/null +++ b/src/tests/mod.rs @@ -0,0 +1,24 @@ + +#[cfg(test)] +mod tests { + + use std::process::Command; + use crate::server::startServer; + + #[tokio::test] + async fn test_serverStart() { + startServer().await; + } + + #[tokio::test] + async fn test_dbconnect() { + startServer().await; + // curl telnet://127.0.0.1:42000 <<< INIT_CONNECTION::onhlt::server::test + Command::new("C:/Windows/System32/curl") + .arg("telnet://127.0.0.1:42000") + .arg("<<<") + .arg("INIT_CONNECTION::onhlt::server::test") + .spawn() + .expect("ls command failed to start"); + } +} \ No newline at end of file