Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: remove unused function

+27 -25
+27 -25
crates/maudit/src/assets/image.rs
··· 260 260 } 261 261 } 262 262 263 - fn get_placeholder(path: &PathBuf, cache: Option<&ImageCache>) -> Result<ImagePlaceholder, crate::errors::AssetError> { 263 + fn get_placeholder( 264 + path: &PathBuf, 265 + cache: Option<&ImageCache>, 266 + ) -> Result<ImagePlaceholder, crate::errors::AssetError> { 264 267 // Check cache first if provided 265 268 if let Some(cache) = cache 266 269 && let Some(cached) = cache.get_placeholder(path) ··· 527 530 use super::*; 528 531 use std::path::PathBuf; 529 532 530 - fn setup_unique_temp_dir() -> tempfile::TempDir { 531 - // Create a unique temporary directory that's automatically cleaned up 532 - tempfile::tempdir().unwrap() 533 - } 534 - 535 533 #[test] 536 534 fn test_placeholder_with_missing_file() { 537 535 let nonexistent_path = PathBuf::from("/this/file/does/not/exist.png"); 538 - 536 + 539 537 let result = get_placeholder(&nonexistent_path, None); 540 - 538 + 541 539 // Should return an error, not panic 542 540 assert!(result.is_err()); 543 - 541 + 544 542 if let Err(crate::errors::AssetError::ImageLoadFailed { path, .. }) = result { 545 543 assert_eq!(path, nonexistent_path); 546 544 } else { ··· 550 548 551 549 #[test] 552 550 fn test_placeholder_with_invalid_image_data() { 553 - let temp_dir = setup_unique_temp_dir(); 554 - 551 + let temp_dir = tempfile::tempdir().unwrap(); 552 + 555 553 // Create a file with invalid image data 556 554 let invalid_image_path = temp_dir.path().join("invalid.png"); 557 555 std::fs::write(&invalid_image_path, b"This is not a valid PNG file").unwrap(); 558 - 556 + 559 557 let result = get_placeholder(&invalid_image_path, None); 560 - 558 + 561 559 // Should return an error, not panic 562 560 assert!(result.is_err()); 563 - 561 + 564 562 if let Err(crate::errors::AssetError::ImageLoadFailed { path, .. }) = result { 565 563 assert_eq!(path, invalid_image_path); 566 564 } else { 567 565 panic!("Expected ImageLoadFailed error"); 568 566 } 569 - 567 + 570 568 // Cleanup 571 569 std::fs::remove_file(&invalid_image_path).ok(); 572 570 } ··· 574 572 #[test] 575 573 fn test_placeholder_with_valid_image() { 576 574 use std::path::Path; 577 - 575 + 578 576 // Try to find an existing image in the examples directory 579 - let project_root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap(); 577 + let project_root = Path::new(env!("CARGO_MANIFEST_DIR")) 578 + .parent() 579 + .unwrap() 580 + .parent() 581 + .unwrap(); 580 582 let test_image = project_root.join("examples/image-processing/images/walrus.jpg"); 581 - 583 + 582 584 // Skip test if the image doesn't exist (e.g., in CI without examples) 583 585 if !test_image.exists() { 584 586 eprintln!("Skipping test: test image not found at {:?}", test_image); 585 587 return; 586 588 } 587 - 589 + 588 590 let result = get_placeholder(&test_image, None); 589 - 591 + 590 592 // Should succeed 591 593 assert!(result.is_ok()); 592 - 594 + 593 595 let placeholder = result.unwrap(); 594 596 // Verify the placeholder has a thumbhash 595 597 assert!(!placeholder.thumbhash.is_empty()); ··· 598 600 599 601 #[test] 600 602 fn test_placeholder_with_empty_file() { 601 - let temp_dir = setup_unique_temp_dir(); 602 - 603 + let temp_dir = tempfile::tempdir().unwrap(); 604 + 603 605 // Create an empty file 604 606 let empty_file_path = temp_dir.path().join("empty.png"); 605 607 std::fs::write(&empty_file_path, b"").unwrap(); 606 - 608 + 607 609 let result = get_placeholder(&empty_file_path, None); 608 - 610 + 609 611 // Should return an error for empty/invalid image 610 612 assert!(result.is_err()); 611 613 }