Files
Arun Raj M d634fdeac3 feat: change async-bb8 fork and tokio spawn for concurrent database calls (#2774)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: akshay-97 <adiosphobian@gmail.com>
Co-authored-by: akshay.s <akshay.s@juspay.in>
Co-authored-by: Kartikeya Hegde <karthikey.hegde@juspay.in>
2023-11-16 04:57:34 +00:00

50 lines
1.1 KiB
Rust

use std::sync::atomic;
use router::{configs::settings::Settings, routes, services};
mod utils;
#[tokio::test]
#[should_panic]
async fn get_redis_conn_failure() {
// Arrange
utils::setup().await;
let (tx, _) = tokio::sync::oneshot::channel();
let state = Box::pin(routes::AppState::new(
Settings::default(),
tx,
Box::new(services::MockApiClient),
))
.await;
let _ = state.store.get_redis_conn().map(|conn| {
conn.is_redis_available
.store(false, atomic::Ordering::SeqCst)
});
// Act
let _ = state.store.get_redis_conn();
// Assert
// based on #[should_panic] attribute
}
#[tokio::test]
async fn get_redis_conn_success() {
// Arrange
Box::pin(utils::setup()).await;
let (tx, _) = tokio::sync::oneshot::channel();
let state = Box::pin(routes::AppState::new(
Settings::default(),
tx,
Box::new(services::MockApiClient),
))
.await;
// Act
let result = state.store.get_redis_conn();
// Assert
assert!(result.is_ok())
}