//! Test helper utilities for QuickDID tests use crate::cache::create_redis_pool; use deadpool_redis::Pool; /// Helper function to get a Redis pool for testing. /// /// Returns None if TEST_REDIS_URL is not set, logging a skip message. /// This consolidates the repeated Redis test setup code. pub(crate) fn get_test_redis_pool() -> Option { match std::env::var("TEST_REDIS_URL") { Ok(url) => match create_redis_pool(&url) { Ok(pool) => Some(pool), Err(e) => { eprintln!("Failed to create Redis pool: {}", e); None } }, Err(_) => { eprintln!("Skipping test: Set TEST_REDIS_URL to run Redis tests"); None } } } /// Macro to skip Redis tests if pool is not available #[macro_export] macro_rules! require_redis { () => { match $crate::test_helpers::get_test_redis_pool() { Some(pool) => pool, None => return, } }; }