diff --git a/tests/test.rs b/tests/test.rs index 5683360..eb80177 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -353,21 +353,7 @@ mod request { #[tokio::test] async fn test_create_contact() { - let tm_pool = db_mgr::get_pool().await.unwrap(); - let db_name = db_mgr::generate_db_name().await; - - match db_mgr::create_database(&tm_pool, &db_name).await { - Ok(_) => { - println!("Success"); - } - Err(err) => { - assert!(false, "Error: {:?}", err); - } - } - - let pool = db_mgr::connect_to_db(&db_name).await.unwrap(); - db::migrations(&pool).await; - + let (tm_pool, db_name, pool) = db_mgr::get_database_ready().await; let app = init::app(pool).await; // Send request @@ -389,21 +375,7 @@ async fn test_create_contact() { #[tokio::test] async fn test_get_contact() { - let tm_pool = db_mgr::get_pool().await.unwrap(); - let db_name = db_mgr::generate_db_name().await; - - match db_mgr::create_database(&tm_pool, &db_name).await { - Ok(_) => { - println!("Success"); - } - Err(err) => { - assert!(false, "Error: {:?}", err); - } - } - - let pool = db_mgr::connect_to_db(&db_name).await.unwrap(); - db::migrations(&pool).await; - + let (tm_pool, db_name, pool) = db_mgr::get_database_ready().await; let app = init::app(pool).await; // Send request @@ -444,21 +416,7 @@ async fn test_get_contact() { #[tokio::test] async fn test_update_contact_names() { - let tm_pool = db_mgr::get_pool().await.unwrap(); - let db_name = db_mgr::generate_db_name().await; - - match db_mgr::create_database(&tm_pool, &db_name).await { - Ok(_) => { - println!("Success"); - } - Err(err) => { - assert!(false, "Error: {:?}", err); - } - } - - let pool = db_mgr::connect_to_db(&db_name).await.unwrap(); - db::migrations(&pool).await; - + let (tm_pool, db_name, pool) = db_mgr::get_database_ready().await; let app = init::app(pool).await; let mut opt_contact: Option = None; @@ -563,7 +521,6 @@ async fn test_create_message() { #[tokio::test] async fn test_get_message() { let (tm_pool, db_name, pool) = db_mgr::get_database_ready().await; - let app = init::app(pool).await; let mut message_result: Option = None;