mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +08:00
Co-authored-by: jeeva <jeeva.ramu@codurance.com> Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
40 lines
895 B
Rust
40 lines
895 B
Rust
use std::sync::atomic;
|
|
|
|
use router::{configs::settings::Settings, routes};
|
|
|
|
mod utils;
|
|
|
|
#[tokio::test]
|
|
#[should_panic]
|
|
async fn get_redis_conn_failure() {
|
|
// Arrange
|
|
utils::setup().await;
|
|
let (tx, _) = tokio::sync::oneshot::channel();
|
|
let state = routes::AppState::new(Settings::default(), tx).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
|
|
utils::setup().await;
|
|
let (tx, _) = tokio::sync::oneshot::channel();
|
|
let state = routes::AppState::new(Settings::default(), tx).await;
|
|
|
|
// Act
|
|
let result = state.store.get_redis_conn();
|
|
|
|
// Assert
|
|
assert!(result.is_ok())
|
|
}
|