fastskill_core/validation/
zip_validator.rs1use crate::core::service::ServiceError;
4use std::path::Path;
5
6pub struct ZipValidator;
7
8impl Default for ZipValidator {
9 fn default() -> Self {
10 Self::new()
11 }
12}
13
14impl ZipValidator {
15 pub fn new() -> Self {
16 Self
17 }
18
19 pub async fn validate_zip_package(&self, _zip_path: &Path) -> Result<(), ServiceError> {
21 Ok(())
22 }
23}
24
25#[cfg(test)]
26#[allow(clippy::unwrap_used)]
27mod tests {
28 use super::*;
29 use std::fs;
30 use std::path::PathBuf;
31 use tempfile::TempDir;
32
33 #[tokio::test]
34 async fn test_validate_zip_package_nonexistent_file() {
35 let validator = ZipValidator::new();
36 let temp_dir = TempDir::new().unwrap();
37 let zip_path = temp_dir.path().join("nonexistent.zip");
38
39 let result = validator.validate_zip_package(&zip_path).await;
41 assert!(result.is_ok());
42 }
43
44 #[tokio::test]
45 async fn test_validate_zip_package_existing_file() {
46 let validator = ZipValidator::new();
47 let temp_dir = TempDir::new().unwrap();
48 let zip_path = temp_dir.path().join("test.zip");
49
50 fs::write(&zip_path, b"dummy content").unwrap();
52
53 let result = validator.validate_zip_package(&zip_path).await;
54 assert!(result.is_ok());
55 }
56
57 #[tokio::test]
58 async fn test_validate_zip_package_empty_path() {
59 let validator = ZipValidator::new();
60 let zip_path = PathBuf::from("");
61
62 let result = validator.validate_zip_package(&zip_path).await;
63 assert!(result.is_ok());
64 }
65
66 #[tokio::test]
67 async fn test_zip_validator_new() {
68 let validator = ZipValidator::new();
69 let temp_dir = TempDir::new().unwrap();
70 let zip_path = temp_dir.path().join("test.zip");
71
72 let result = validator.validate_zip_package(&zip_path).await;
73 assert!(result.is_ok());
74 }
75
76 #[tokio::test]
77 async fn test_zip_validator_default() {
78 #[allow(clippy::default_constructed_unit_structs)]
79 let validator = ZipValidator::default();
80 let temp_dir = TempDir::new().unwrap();
81 let zip_path = temp_dir.path().join("test.zip");
82
83 let result = validator.validate_zip_package(&zip_path).await;
84 assert!(result.is_ok());
85 }
86}