Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(db): Implement `ReverseLookupInterface` for `MockDb` (#2119)
Hudson C. Dalpráf2df2d6d01a1
diff --git a/crates/diesel_models/src/reverse_lookup.rs b/crates/diesel_models/src/reverse_lookup.rsindex 8cc85cc818..a72b23accc 100644--- a/crates/diesel_models/src/reverse_lookup.rs+++ b/crates/diesel_models/src/reverse_lookup.rs@@ -31,3 +31,14 @@ pub struct ReverseLookupNew {pub sk_id: String,pub source: String,}++impl From<ReverseLookupNew> for ReverseLookup {+ fn from(new: ReverseLookupNew) -> Self {+ Self {+ lookup_id: new.lookup_id,+ sk_id: new.sk_id,+ pk_id: new.pk_id,+ source: new.source,+ }+ }+}diff --git a/crates/router/src/db/reverse_lookup.rs b/crates/router/src/db/reverse_lookup.rsindex 0daa81cf25..51eba99ea0 100644--- a/crates/router/src/db/reverse_lookup.rs+++ b/crates/router/src/db/reverse_lookup.rs@@ -48,14 +48,31 @@ impl ReverseLookupInterface for Store {impl ReverseLookupInterface for MockDb {async fn insert_reverse_lookup(&self,- _new: ReverseLookupNew,+ new: ReverseLookupNew,) -> CustomResult<ReverseLookup, errors::StorageError> {- Err(errors::StorageError::MockDbError.into())+ let reverse_lookup_insert = ReverseLookup::from(new);+ self.reverse_lookups+ .lock()+ .await+ .push(reverse_lookup_insert.clone());+ Ok(reverse_lookup_insert)}async fn get_lookup_by_lookup_id(&self,- _id: &str,+ lookup_id: &str,) -> CustomResult<ReverseLookup, errors::StorageError> {- Err(errors::StorageError::MockDbError.into())+ self.reverse_lookups+ .lock()+ .await+ .iter()+ .find(|reverse_lookup| reverse_lookup.lookup_id == lookup_id)+ .ok_or(+ errors::StorageError::ValueNotFound(format!(+ "No reverse lookup found for lookup_id = {}",+ lookup_id+ ))+ .into(),+ )+ .cloned()}}diff --git a/crates/storage_impl/src/mock_db.rs b/crates/storage_impl/src/mock_db.rsindex 81242af9c7..e41d7a3aba 100644--- a/crates/storage_impl/src/mock_db.rs+++ b/crates/storage_impl/src/mock_db.rs@@ -39,6 +39,7 @@ pub struct MockDb {pub captures: Arc<Mutex<Vec<crate::store::capture::Capture>>>,pub merchant_key_store: Arc<Mutex<Vec<crate::store::merchant_key_store::MerchantKeyStore>>>,pub business_profiles: Arc<Mutex<Vec<crate::store::business_profile::BusinessProfile>>>,+ pub reverse_lookups: Arc<Mutex<Vec<store::ReverseLookup>>>,}impl MockDb {@@ -70,6 +71,7 @@ impl MockDb {captures: Default::default(),merchant_key_store: Default::default(),business_profiles: Default::default(),+ reverse_lookups: Default::default(),})}}