mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 18:37:46 +08:00
fix(admin): classify bulk wallet adjustment failures
This commit is contained in:
@@ -494,6 +494,8 @@ pub struct AppState {
|
||||
#[cfg(test)]
|
||||
pub(crate) auth_wallet_adjustment_error_for_tests: Option<String>,
|
||||
#[cfg(test)]
|
||||
pub(crate) auth_wallet_lookup_error_for_tests: Option<String>,
|
||||
#[cfg(test)]
|
||||
pub(crate) admin_wallet_payment_order_store:
|
||||
Option<Arc<StdMutex<HashMap<String, AdminWalletPaymentOrderRecord>>>>,
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -468,6 +468,8 @@ impl AppState {
|
||||
#[cfg(test)]
|
||||
auth_wallet_adjustment_error_for_tests: None,
|
||||
#[cfg(test)]
|
||||
auth_wallet_lookup_error_for_tests: None,
|
||||
#[cfg(test)]
|
||||
admin_wallet_payment_order_store: Some(Arc::new(StdMutex::new(HashMap::new()))),
|
||||
#[cfg(test)]
|
||||
admin_payment_callback_store: Some(Arc::new(StdMutex::new(HashMap::new()))),
|
||||
|
||||
@@ -5,6 +5,19 @@ impl AppState {
|
||||
&self,
|
||||
lookup: aether_data::repository::wallet::WalletLookupKey<'_>,
|
||||
) -> Result<Option<aether_data::repository::wallet::StoredWalletSnapshot>, GatewayError> {
|
||||
#[cfg(test)]
|
||||
if let Some(failed_user_id) = self.auth_wallet_lookup_error_for_tests.as_deref() {
|
||||
let lookup_user_id = match &lookup {
|
||||
aether_data::repository::wallet::WalletLookupKey::UserId(user_id) => Some(*user_id),
|
||||
_ => None,
|
||||
};
|
||||
if lookup_user_id == Some(failed_user_id) {
|
||||
return Err(GatewayError::Internal(
|
||||
"injected test wallet lookup failure".to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
if let Some(store) = self.auth_wallet_store.as_ref() {
|
||||
let wallet = {
|
||||
|
||||
@@ -480,6 +480,11 @@ impl AppState {
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn fail_auth_wallet_lookup_for_tests(mut self, user_id: impl Into<String>) -> Self {
|
||||
self.auth_wallet_lookup_error_for_tests = Some(user_id.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn with_admin_wallet_payment_orders_for_tests<I>(mut self, orders: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = crate::AdminWalletPaymentOrderRecord>,
|
||||
|
||||
Reference in New Issue
Block a user