QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides handle-to-DID resolution with Redis-backed caching and queue processing.
at main 35 lines 1.0 kB view raw
1//! Test helper utilities for QuickDID tests 2 3use crate::cache::create_redis_pool; 4use deadpool_redis::Pool; 5 6/// Helper function to get a Redis pool for testing. 7/// 8/// Returns None if TEST_REDIS_URL is not set, logging a skip message. 9/// This consolidates the repeated Redis test setup code. 10pub(crate) fn get_test_redis_pool() -> Option<Pool> { 11 match std::env::var("TEST_REDIS_URL") { 12 Ok(url) => match create_redis_pool(&url) { 13 Ok(pool) => Some(pool), 14 Err(e) => { 15 eprintln!("Failed to create Redis pool: {}", e); 16 None 17 } 18 }, 19 Err(_) => { 20 eprintln!("Skipping test: Set TEST_REDIS_URL to run Redis tests"); 21 None 22 } 23 } 24} 25 26/// Macro to skip Redis tests if pool is not available 27#[macro_export] 28macro_rules! require_redis { 29 () => { 30 match $crate::test_helpers::get_test_redis_pool() { 31 Some(pool) => pool, 32 None => return, 33 } 34 }; 35}