From 0465b4665094089953fbeab7578c26d31ea84654 Mon Sep 17 00:00:00 2001 From: EETagent Date: Mon, 5 Dec 2022 20:25:04 +0100 Subject: [PATCH] feat: test cache delete functions --- core/src/services/portfolio_service.rs | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/core/src/services/portfolio_service.rs b/core/src/services/portfolio_service.rs index c122cc9..556f31c 100644 --- a/core/src/services/portfolio_service.rs +++ b/core/src/services/portfolio_service.rs @@ -430,6 +430,20 @@ mod tests { clear_data_store_temp_dir(temp_dir).await; } + #[tokio::test] + #[serial] + async fn test_delete_cover_letter_from_cache() { + let (temp_dir, _, application_cache_dir) = create_data_store_temp_dir(APPLICATION_ID).await; + + PortfolioService::add_cover_letter_to_cache(APPLICATION_ID, vec![0]).await.unwrap(); + + PortfolioService::delete_cover_letter_from_cache(APPLICATION_ID).await.unwrap(); + + assert!(tokio::fs::metadata(application_cache_dir.join("MOTIVACNI_DOPIS.pdf")).await.is_err()); + + clear_data_store_temp_dir(temp_dir).await; + } + #[tokio::test] #[serial] async fn test_is_cover_letter() { @@ -442,6 +456,21 @@ mod tests { clear_data_store_temp_dir(temp_dir).await; } + #[tokio::test] + #[serial] + async fn test_delete_cache_item() { + let (temp_dir, _, application_cache_dir) = create_data_store_temp_dir(APPLICATION_ID).await; + + PortfolioService::add_cover_letter_to_cache(APPLICATION_ID, vec![0]).await.unwrap(); + + PortfolioService::delete_cache_item(APPLICATION_ID, FileType::CoverLetterPdf).await.unwrap(); + + assert!(tokio::fs::metadata(application_cache_dir.join("MOTIVACNI_DOPIS.pdf")).await.is_err()); + + clear_data_store_temp_dir(temp_dir).await; + } + + #[tokio::test] #[serial] async fn test_add_portfolio_letter_to_cache() { @@ -454,6 +483,20 @@ mod tests { clear_data_store_temp_dir(temp_dir).await; } + #[tokio::test] + #[serial] + async fn test_delete_portfolio_letter_from_cache() { + let (temp_dir, _, application_cache_dir) = create_data_store_temp_dir(APPLICATION_ID).await; + + PortfolioService::add_portfolio_letter_to_cache(APPLICATION_ID, vec![0]).await.unwrap(); + + PortfolioService::delete_portfolio_letter_from_cache(APPLICATION_ID).await.unwrap(); + + assert!(tokio::fs::metadata(application_cache_dir.join("PORTFOLIO.pdf")).await.is_err()); + + clear_data_store_temp_dir(temp_dir).await; + } + #[tokio::test] #[serial] async fn test_is_portfolio_letter() { @@ -478,6 +521,20 @@ mod tests { clear_data_store_temp_dir(temp_dir).await; } + #[tokio::test] + #[serial] + async fn test_delete_portfolio_zip_from_cache() { + let (temp_dir, _, application_cache_dir) = create_data_store_temp_dir(APPLICATION_ID).await; + + PortfolioService::add_portfolio_zip_to_cache(APPLICATION_ID, vec![0]).await.unwrap(); + + PortfolioService::delete_portfolio_zip_from_cache(APPLICATION_ID).await.unwrap(); + + assert!(tokio::fs::metadata(application_cache_dir.join("PORTFOLIO.zip")).await.is_err()); + + clear_data_store_temp_dir(temp_dir).await; + } + #[tokio::test] #[serial] async fn test_is_portfolio_zip() {