From 2acbdf179e35a133c8b7aa62cca623c37f852466 Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Fri, 5 Apr 2024 19:32:47 +0100 Subject: [PATCH] fix(ssg): :bug: unit tests fixes --- tests/test_utilities.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_utilities.rs b/tests/test_utilities.rs index 82d4ad19..d9a2ad7b 100644 --- a/tests/test_utilities.rs +++ b/tests/test_utilities.rs @@ -85,12 +85,12 @@ mod tests { } #[test] - fn test_move_output_directory() -> std::io::Result<()> { + fn test_move_output_directory() -> io::Result<()> { // Setup: Create a dummy output directory and a dummy file inside it. let out_dir = Path::new("temp_out_dir"); let dummy_file = out_dir.join("dummy_file.txt"); fs::create_dir_all(out_dir)?; - fs::File::create(dummy_file)?; + File::create(dummy_file)?; // Call the function to test. let site_name = "My Test Site"; @@ -116,12 +116,12 @@ mod tests { } #[test] - fn test_minify_html_files() -> std::io::Result<()> { + fn test_minify_html_files() -> io::Result<()> { // Setup: Create a dummy output directory and a dummy HTML file inside it. let out_dir = Path::new("tests/test_output"); let dummy_file = out_dir.join("dummy_file.html"); fs::create_dir_all(out_dir)?; - let mut file = fs::File::create(&dummy_file)?; + let mut file = File::create(&dummy_file)?; file.write_all( b"\n\nHello, World!\n\n", )?; @@ -151,7 +151,7 @@ mod tests { } #[test] - fn test_find_html_files() -> std::io::Result<()> { + fn test_find_html_files() -> io::Result<()> { // Setup: Create a directory with a few .html files and a subdirectory // with a few more .html files. let dir = Path::new("temp_dir"); @@ -216,10 +216,10 @@ mod tests { Ok(()) } #[test] - fn test_backup_file() -> std::io::Result<()> { + fn test_backup_file() -> io::Result<()> { // Setup: Create a dummy file. let file_path = Path::new("temp_file.txt"); - let mut file = fs::File::create(file_path)?; + let mut file = File::create(file_path)?; file.write_all(b"Some text for the dummy file")?; // Call the function to test. @@ -240,7 +240,7 @@ mod tests { Ok(()) } #[test] - fn test_write_minified_html() -> std::io::Result<()> { + fn test_write_minified_html() -> io::Result<()> { // Setup: Define a dummy file path and minified HTML. let file_path = Path::new("temp_minified_html_file.html"); let minified_html = "Test

Hello, World!

"; @@ -252,7 +252,7 @@ mod tests { assert!(file_path.exists(), "The file was not created."); // Check that the file contains the expected minified HTML. - let mut file = fs::File::open(file_path)?; + let mut file = File::open(file_path)?; let mut contents = String::new(); file.read_to_string(&mut contents)?; assert_eq!( @@ -272,12 +272,12 @@ mod tests { let dir1 = Path::new("temp_dir1"); let dummy_file1 = dir1.join("dummy_file1.txt"); fs::create_dir_all(dir1)?; - fs::File::create(dummy_file1)?; + File::create(dummy_file1)?; let dir2 = Path::new("temp_dir2"); let dummy_file2 = dir2.join("dummy_file2.txt"); fs::create_dir_all(dir2)?; - fs::File::create(dummy_file2)?; + File::create(dummy_file2)?; let directories: Vec<&Path> = vec![dir1, dir2];