use super::error::StorageResult;
use super::global::GlobalStorage;
pub struct StorageFactory;
impl StorageFactory {
pub async fn from_env() -> StorageResult<GlobalStorage> {
GlobalStorage::new()
}
#[cfg(test)]
pub fn create_test_storage() -> StorageResult<GlobalStorage> {
GlobalStorage::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_factory_creates_global_storage() {
let storage = StorageFactory::from_env().await.unwrap();
let health = storage.health_check().await.unwrap();
assert!(health.healthy);
}
#[test]
fn test_factory_creates_test_storage() {
let storage = StorageFactory::create_test_storage().unwrap();
assert!(storage.base_dir().exists());
}
}