From 8761a4280ff8cb6e4b45954b903a511cecb00cb3 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 14 Mar 2024 14:34:11 -0400 Subject: [PATCH] Fix integration test --- limitador-server/src/main.rs | 2 +- limitador/tests/integration_tests.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/limitador-server/src/main.rs b/limitador-server/src/main.rs index 83fd9047..ff5c9370 100644 --- a/limitador-server/src/main.rs +++ b/limitador-server/src/main.rs @@ -201,7 +201,7 @@ impl Limiter { }; let mut rate_limiter_builder = - AsyncRateLimiterBuilder::new(AsyncStorage::with_counter_storage(Box::new(storage))); + AsyncRateLimiterBuilder::new(AsyncStorage::with_counter_storage(Arc::new(storage))); if limit_name_labels { rate_limiter_builder = rate_limiter_builder.with_prometheus_limit_name_labels() diff --git a/limitador/tests/integration_tests.rs b/limitador/tests/integration_tests.rs index d300c46f..1f5b77db 100644 --- a/limitador/tests/integration_tests.rs +++ b/limitador/tests/integration_tests.rs @@ -49,7 +49,7 @@ macro_rules! test_with_all_storage_impls { let storage = AsyncRedisStorage::new("redis://127.0.0.1:6379").await.expect("We need a Redis running locally"); storage.clear().await.unwrap(); let rate_limiter = AsyncRateLimiter::new_with_storage( - Box::new(storage) + Arc::new(storage) ); AsyncRedisStorage::new("redis://127.0.0.1:6379").await.expect("We need a Redis running locally").clear().await.unwrap(); $function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await; @@ -64,7 +64,7 @@ macro_rules! test_with_all_storage_impls { ).build().await; storage.clear().await.unwrap(); let rate_limiter = AsyncRateLimiter::new_with_storage( - Box::new(storage) + Arc::new(storage) ); $function(&mut TestsLimiter::new_from_async_impl(rate_limiter)).await; } @@ -81,6 +81,7 @@ mod test { // To be able to pass the tests without Redis cfg_if::cfg_if! { if #[cfg(feature = "redis_storage")] { + use std::sync::Arc; use limitador::storage::redis::AsyncRedisStorage; use limitador::storage::redis::RedisStorage;