Skip to content

Commit dcbb41a

Browse files
committed
create test_file_size_limit
1 parent 81b3673 commit dcbb41a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/tools/filesystem.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,25 @@ mod tests {
323323
let child_entries = fs_tool.list_directory("parent/child").unwrap();
324324
assert_eq!(child_entries, vec!["file2.txt"]);
325325
}
326+
327+
#[test]
328+
fn test_file_size_limit() {
329+
let temp_dir = tempfile::tempdir().unwrap();
330+
let fs_tool = FileSystemTool::new(temp_dir.path().to_path_buf()).unwrap();
331+
332+
// Create a file larger than 50MB (51MB)
333+
let large_data = vec![0u8; 51 * 1024 * 1024];
334+
fs_tool.write_file("large_file.bin", &String::from_utf8_lossy(&large_data)).unwrap();
335+
336+
let result = fs_tool.read_file("large_file.bin");
337+
assert!(result.is_err());
338+
339+
let err = result.unwrap_err();
340+
assert!(matches!(err, SofosError::InvalidPath(_)));
341+
342+
if let SofosError::InvalidPath(msg) = err {
343+
assert!(msg.contains("too large"));
344+
assert!(msg.contains("50 MB"));
345+
}
346+
}
326347
}

0 commit comments

Comments
 (0)