//! Common test utilities for E2E tests

use do_memory_core::SelfLearningMemory;
use do_memory_storage_redb::RedbStorage;
use std::sync::Arc;
use tempfile::tempdir;

/// Helper to create a memory instance with storage
pub async fn setup_test_memory() -> (Arc<SelfLearningMemory>, tempfile::TempDir) {
    let dir = tempdir().unwrap();
    let turso_path = dir.path().join("test_turso.redb");
    let cache_path = dir.path().join("test_cache.redb");

    let turso_storage = RedbStorage::new(&turso_path)
        .await
        .expect("Failed to create turso storage");
    let cache_storage = RedbStorage::new(&cache_path)
        .await
        .expect("Failed to create cache storage");

    let memory = Arc::new(SelfLearningMemory::with_storage(
        Default::default(),
        Arc::new(turso_storage),
        Arc::new(cache_storage),
    ));

    (memory, dir)
}
