use crate::errors::AppError;
use crate::fs::{copy_dir, DirectoryReader};
use crate::testing::TempDirectory;
use std::fs::read_dir;
use std::path::PathBuf;
#[tokio::test]
async fn test_copy_dir() -> Result<(), AppError> {
let source_dir = read_dir(PathBuf::from("./content"))
.or_else(|e| AppError::io(e, "read source dir"))?
.filter_map(Result::ok) .find(|entry| entry.path().is_dir())
.map(|entry| entry.path())
.expect("Should have a directory");
let target_dir = TempDirectory::create("caesura").join("target");
copy_dir(&source_dir, &target_dir, false).await?;
let source_files: Vec<PathBuf> = DirectoryReader::new()
.read(&source_dir)
.expect("Should be able to read dir");
let target_files = DirectoryReader::new()
.read(&target_dir)
.expect("Should be able to read source dir");
assert_eq!(source_files.len(), target_files.len());
Ok(())
}