Skip to content

Commit

Permalink
sentry - db - re-export redis::cmd in redis_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
elpiel committed Nov 3, 2021
1 parent 083cfba commit f76c58a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions sentry/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use tokio_postgres::Config as PostgresConfig;
// Re-export the Postgres PoolError for easier usages
pub use deadpool_postgres::PoolError;
// Re-export the redis RedisError for easier usage
pub use redis::{RedisError, cmd as redis_cmd};
pub use redis::RedisError;

pub type DbPool = deadpool_postgres::Pool;

Expand Down Expand Up @@ -138,7 +138,7 @@ pub async fn setup_migrations(environment: Environment) {
.expect("Reloading config for migration failed");
}

#[cfg(any(test, feature = "test-util"))]
#[cfg(feature = "test-util")]
pub mod tests_postgres {
use std::{
ops::{Deref, DerefMut},
Expand Down Expand Up @@ -428,7 +428,7 @@ pub mod tests_postgres {
}
}

#[cfg(test)]
#[cfg(feature = "test-util")]
pub mod redis_pool {

use dashmap::DashMap;
Expand All @@ -442,6 +442,9 @@ pub mod redis_pool {

use super::*;

/// Re-export [`redis::cmd`] for testing purposes
pub use redis::cmd;

pub type Pool = deadpool::managed::Pool<Manager>;

pub static TESTS_POOL: Lazy<Pool> =
Expand Down
10 changes: 5 additions & 5 deletions test_harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,8 @@ pub mod run {
use sentry::{
application::{logger, run},
db::{
postgres_connection, redis_connection, tests_postgres::setup_test_migrations,
CampaignRemaining,
postgres_connection, redis_connection, redis_pool::Manager,
tests_postgres::setup_test_migrations, CampaignRemaining,
},
Application,
};
Expand Down Expand Up @@ -729,9 +729,9 @@ pub mod run {

let postgres = postgres_connection(42, postgres_config).await;
let mut redis = redis_connection(app_config.redis_url).await?;
sentry::db::redis_cmd("FLUSHDB")
.query_async::<_, String>(&mut redis)
.await.unwrap();

Manager::flush_db(&mut redis).await.expect("Should flush redis database");

let campaign_remaining = CampaignRemaining::new(redis.clone());

setup_test_migrations(postgres.clone())
Expand Down

0 comments on commit f76c58a

Please sign in to comment.