Skip to main content

prodigy/storage/
factory.rs

1//! Storage factory for creating storage instances
2
3use super::error::StorageResult;
4use super::global::GlobalStorage;
5
6/// Factory for creating storage instances
7pub struct StorageFactory;
8
9impl StorageFactory {
10    /// Create storage from environment configuration
11    pub async fn from_env() -> StorageResult<GlobalStorage> {
12        GlobalStorage::new()
13    }
14
15    /// Create a test storage instance
16    #[cfg(test)]
17    pub fn create_test_storage() -> StorageResult<GlobalStorage> {
18        GlobalStorage::new()
19    }
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[tokio::test]
27    async fn test_factory_creates_global_storage() {
28        let storage = StorageFactory::from_env().await.unwrap();
29        let health = storage.health_check().await.unwrap();
30        assert!(health.healthy);
31    }
32
33    #[test]
34    fn test_factory_creates_test_storage() {
35        let storage = StorageFactory::create_test_storage().unwrap();
36        // The storage should be usable
37        // Storage interface methods have been removed - storage operations now go through unified session manager
38        assert!(storage.base_dir().exists());
39    }
40}