diff --git a/src/tests/common/test_helpers.rs b/src/tests/common/test_helpers.rs index 24c7603..266de3d 100644 --- a/src/tests/common/test_helpers.rs +++ b/src/tests/common/test_helpers.rs @@ -120,3 +120,27 @@ pub fn assert_files_equal(path1: &PathBuf, path2: &PathBuf) { let content2 = std::fs::read(path2).expect("Failed to read second file"); assert_eq!(content1, content2, "Files {:?} and {:?} have different content", path1, path2); } + +/// Create a temporary file with binary content +pub fn create_temp_file_with_binary_content(dir: &TempDir, filename: &str, content: &[u8]) -> PathBuf { + let file_path = dir.path().join(filename); + let mut file = File::create(&file_path).expect("Failed to create test file"); + file.write_all(content).expect("Failed to write binary content to test file"); + file_path +} + +/// Get the size of a file +pub fn get_file_size(file_path: &PathBuf) -> u64 { + let metadata = std::fs::metadata(file_path).expect("Failed to get file metadata"); + metadata.len() +} + +/// Assert that a file exists +pub fn assert_file_exists(file_path: &PathBuf) { + assert!(file_path.exists(), "File {:?} does not exist", file_path); +} + +/// Assert that a file does not exist +pub fn assert_file_not_exists(file_path: &PathBuf) { + assert!(!file_path.exists(), "File {:?} should not exist but it does", file_path); +}