fix: remove and resolve FIXMEs and TODOs from db module (#174)

This commit is contained in:
Nishant Joshi
2022-12-20 17:55:24 +05:30
committed by GitHub
parent f3d3abf060
commit 76b47e64c4
22 changed files with 130 additions and 65 deletions

View File

@ -10,7 +10,8 @@
clippy::panicking_unwrap, clippy::panicking_unwrap,
clippy::unreachable, clippy::unreachable,
clippy::unwrap_in_result, clippy::unwrap_in_result,
clippy::unwrap_used clippy::unwrap_used,
clippy::unimplemented
)] )]
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR" ), "/", "README.md"))] #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR" ), "/", "README.md"))]

View File

@ -76,6 +76,8 @@ pub enum StorageError {
DuplicateValue(String), DuplicateValue(String),
#[error("KV error")] #[error("KV error")]
KVError, KVError,
#[error("MockDb error")]
MockDbError,
} }
impl From<error_stack::Report<storage_errors::DatabaseError>> for StorageError { impl From<error_stack::Report<storage_errors::DatabaseError>> for StorageError {

View File

@ -95,7 +95,8 @@ impl AddressInterface for MockDb {
&self, &self,
_address_id: &str, _address_id: &str,
) -> CustomResult<storage::Address, errors::StorageError> { ) -> CustomResult<storage::Address, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_address( async fn update_address(
@ -103,14 +104,16 @@ impl AddressInterface for MockDb {
_address_id: String, _address_id: String,
_address: storage::AddressUpdate, _address: storage::AddressUpdate,
) -> CustomResult<storage::Address, errors::StorageError> { ) -> CustomResult<storage::Address, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_address( async fn insert_address(
&self, &self,
_address: storage::AddressNew, _address: storage::AddressNew,
) -> CustomResult<storage::Address, errors::StorageError> { ) -> CustomResult<storage::Address, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_address_by_merchant_id_customer_id( async fn update_address_by_merchant_id_customer_id(
@ -119,6 +122,7 @@ impl AddressInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_address: storage::AddressUpdate, _address: storage::AddressUpdate,
) -> CustomResult<Vec<storage::Address>, errors::StorageError> { ) -> CustomResult<Vec<storage::Address>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -64,14 +64,16 @@ impl ConfigInterface for MockDb {
&self, &self,
_config: storage::ConfigNew, _config: storage::ConfigNew,
) -> CustomResult<storage::Config, errors::StorageError> { ) -> CustomResult<storage::Config, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_config_by_key( async fn find_config_by_key(
&self, &self,
_key: &str, _key: &str,
) -> CustomResult<storage::Config, errors::StorageError> { ) -> CustomResult<storage::Config, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_config_by_key( async fn update_config_by_key(
@ -79,6 +81,7 @@ impl ConfigInterface for MockDb {
_key: &str, _key: &str,
_config_update: storage::ConfigUpdate, _config_update: storage::ConfigUpdate,
) -> CustomResult<storage::Config, errors::StorageError> { ) -> CustomResult<storage::Config, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -110,9 +110,12 @@ impl ConnectorResponseInterface for MockDb {
_txn_id: &str, _txn_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<storage::ConnectorResponse, errors::StorageError> { ) -> CustomResult<storage::ConnectorResponse, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
// safety: interface only used for testing
#[allow(clippy::unwrap_used)]
async fn update_connector_response( async fn update_connector_response(
&self, &self,
this: storage::ConnectorResponse, this: storage::ConnectorResponse,

View File

@ -133,7 +133,8 @@ impl CustomerInterface for MockDb {
_merchant_id: String, _merchant_id: String,
_customer: storage::CustomerUpdate, _customer: storage::CustomerUpdate,
) -> CustomResult<storage::Customer, errors::StorageError> { ) -> CustomResult<storage::Customer, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_customer_by_customer_id_merchant_id( async fn find_customer_by_customer_id_merchant_id(
@ -141,7 +142,8 @@ impl CustomerInterface for MockDb {
_customer_id: &str, _customer_id: &str,
_merchant_id: &str, _merchant_id: &str,
) -> CustomResult<storage::Customer, errors::StorageError> { ) -> CustomResult<storage::Customer, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
#[allow(clippy::panic)] #[allow(clippy::panic)]
@ -171,6 +173,7 @@ impl CustomerInterface for MockDb {
_customer_id: &str, _customer_id: &str,
_merchant_id: &str, _merchant_id: &str,
) -> CustomResult<bool, errors::StorageError> { ) -> CustomResult<bool, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -32,6 +32,7 @@ impl EventInterface for MockDb {
&self, &self,
_event: storage::EventNew, _event: storage::EventNew,
) -> CustomResult<storage::Event, errors::StorageError> { ) -> CustomResult<storage::Event, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -64,20 +64,23 @@ impl LockerMockUpInterface for MockDb {
&self, &self,
_card_id: &str, _card_id: &str,
) -> CustomResult<storage::LockerMockUp, errors::StorageError> { ) -> CustomResult<storage::LockerMockUp, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_locker_mock_up( async fn insert_locker_mock_up(
&self, &self,
_new: storage::LockerMockUpNew, _new: storage::LockerMockUpNew,
) -> CustomResult<storage::LockerMockUp, errors::StorageError> { ) -> CustomResult<storage::LockerMockUp, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn delete_locker_mock_up( async fn delete_locker_mock_up(
&self, &self,
_card_id: &str, _card_id: &str,
) -> CustomResult<storage::LockerMockUp, errors::StorageError> { ) -> CustomResult<storage::LockerMockUp, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -93,7 +93,8 @@ impl MandateInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_mandate_id: &str, _mandate_id: &str,
) -> CustomResult<storage::Mandate, errors::StorageError> { ) -> CustomResult<storage::Mandate, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_mandate_by_merchant_id_customer_id( async fn find_mandate_by_merchant_id_customer_id(
@ -101,7 +102,8 @@ impl MandateInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_customer_id: &str, _customer_id: &str,
) -> CustomResult<Vec<storage::Mandate>, errors::StorageError> { ) -> CustomResult<Vec<storage::Mandate>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_mandate_by_merchant_id_mandate_id( async fn update_mandate_by_merchant_id_mandate_id(
@ -110,13 +112,15 @@ impl MandateInterface for MockDb {
_mandate_id: &str, _mandate_id: &str,
_mandate: storage::MandateUpdate, _mandate: storage::MandateUpdate,
) -> CustomResult<storage::Mandate, errors::StorageError> { ) -> CustomResult<storage::Mandate, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_mandate( async fn insert_mandate(
&self, &self,
_mandate: storage::MandateNew, _mandate: storage::MandateNew,
) -> CustomResult<storage::Mandate, errors::StorageError> { ) -> CustomResult<storage::Mandate, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -159,7 +159,8 @@ impl MerchantAccountInterface for MockDb {
match account { match account {
Some(account) => Ok(account.clone()), Some(account) => Ok(account.clone()),
None => todo!(), // [#172]: Implement function for `MockDb`
None => Err(errors::StorageError::MockDbError)?,
} }
} }
@ -168,7 +169,8 @@ impl MerchantAccountInterface for MockDb {
_this: storage::MerchantAccount, _this: storage::MerchantAccount,
_merchant_account: storage::MerchantAccountUpdate, _merchant_account: storage::MerchantAccountUpdate,
) -> CustomResult<storage::MerchantAccount, errors::StorageError> { ) -> CustomResult<storage::MerchantAccount, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
#[allow(clippy::panic)] #[allow(clippy::panic)]
@ -190,13 +192,15 @@ impl MerchantAccountInterface for MockDb {
&self, &self,
_publishable_key: &str, _publishable_key: &str,
) -> CustomResult<storage::MerchantAccount, errors::StorageError> { ) -> CustomResult<storage::MerchantAccount, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn delete_merchant_account_by_merchant_id( async fn delete_merchant_account_by_merchant_id(
&self, &self,
_merchant_id: &str, _merchant_id: &str,
) -> CustomResult<bool, errors::StorageError> { ) -> CustomResult<bool, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -129,6 +129,8 @@ impl MerchantConnectorAccountInterface for Store {
#[async_trait::async_trait] #[async_trait::async_trait]
impl MerchantConnectorAccountInterface for MockDb { impl MerchantConnectorAccountInterface for MockDb {
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn find_merchant_connector_account_by_merchant_id_connector( async fn find_merchant_connector_account_by_merchant_id_connector(
&self, &self,
merchant_id: &str, merchant_id: &str,
@ -150,7 +152,8 @@ impl MerchantConnectorAccountInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_merchant_connector_id: &i32, _merchant_connector_id: &i32,
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> { ) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
#[allow(clippy::panic)] #[allow(clippy::panic)]
@ -181,7 +184,8 @@ impl MerchantConnectorAccountInterface for MockDb {
&self, &self,
_merchant_id: &str, _merchant_id: &str,
) -> CustomResult<Vec<storage::MerchantConnectorAccount>, errors::StorageError> { ) -> CustomResult<Vec<storage::MerchantConnectorAccount>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_merchant_connector_account( async fn update_merchant_connector_account(
@ -189,7 +193,8 @@ impl MerchantConnectorAccountInterface for MockDb {
_this: storage::MerchantConnectorAccount, _this: storage::MerchantConnectorAccount,
_merchant_connector_account: storage::MerchantConnectorAccountUpdate, _merchant_connector_account: storage::MerchantConnectorAccountUpdate,
) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> { ) -> CustomResult<storage::MerchantConnectorAccount, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id( async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(
@ -197,6 +202,7 @@ impl MerchantConnectorAccountInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_merchant_connector_id: &i32, _merchant_connector_id: &i32,
) -> CustomResult<bool, errors::StorageError> { ) -> CustomResult<bool, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -152,8 +152,6 @@ mod storage {
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<PaymentAttempt, errors::StorageError> { ) -> CustomResult<PaymentAttempt, errors::StorageError> {
let conn = pg_connection(&self.master_pool).await; let conn = pg_connection(&self.master_pool).await;
// TODO: update logic to lookup all payment attempts for an intent
// and apply filter logic on top of them to get the desired one.
PaymentAttempt::find_by_merchant_id_connector_txn_id( PaymentAttempt::find_by_merchant_id_connector_txn_id(
&conn, &conn,
merchant_id, merchant_id,
@ -188,7 +186,8 @@ impl PaymentAttemptInterface for MockDb {
_attempt_id: &str, _attempt_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::PaymentAttempt, errors::StorageError> { ) -> CustomResult<types::PaymentAttempt, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_payment_attempt_by_merchant_id_connector_txn_id( async fn find_payment_attempt_by_merchant_id_connector_txn_id(
@ -197,7 +196,8 @@ impl PaymentAttemptInterface for MockDb {
_connector_txn_id: &str, _connector_txn_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::PaymentAttempt, errors::StorageError> { ) -> CustomResult<types::PaymentAttempt, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
#[allow(clippy::panic)] #[allow(clippy::panic)]
@ -247,6 +247,8 @@ impl PaymentAttemptInterface for MockDb {
Ok(payment_attempt) Ok(payment_attempt)
} }
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn update_payment_attempt( async fn update_payment_attempt(
&self, &self,
this: types::PaymentAttempt, this: types::PaymentAttempt,
@ -271,7 +273,8 @@ impl PaymentAttemptInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::PaymentAttempt, errors::StorageError> { ) -> CustomResult<types::PaymentAttempt, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_payment_attempt_by_transaction_id_payment_id_merchant_id( async fn find_payment_attempt_by_transaction_id_payment_id_merchant_id(
@ -281,9 +284,12 @@ impl PaymentAttemptInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<types::PaymentAttempt, errors::StorageError> { ) -> CustomResult<types::PaymentAttempt, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id( async fn find_payment_attempt_last_successful_attempt_by_payment_id_merchant_id(
&self, &self,
payment_id: &str, payment_id: &str,
@ -341,10 +347,9 @@ mod storage {
"{}_{}", "{}_{}",
payment_attempt.merchant_id, payment_attempt.payment_id payment_attempt.merchant_id, payment_attempt.payment_id
); );
// TODO: need to add an application generated payment attempt id to distinguish between multiple attempts for the same payment id
// Check for database presence as well Maybe use a read replica here ?
let created_attempt = PaymentAttempt { let created_attempt = PaymentAttempt {
id: 0i32, id: Default::default(),
payment_id: payment_attempt.payment_id.clone(), payment_id: payment_attempt.payment_id.clone(),
merchant_id: payment_attempt.merchant_id.clone(), merchant_id: payment_attempt.merchant_id.clone(),
attempt_id: payment_attempt.attempt_id.clone(), attempt_id: payment_attempt.attempt_id.clone(),
@ -611,8 +616,6 @@ mod storage {
match storage_scheme { match storage_scheme {
enums::MerchantStorageScheme::PostgresOnly => { enums::MerchantStorageScheme::PostgresOnly => {
let conn = pg_connection(&self.master_pool).await; let conn = pg_connection(&self.master_pool).await;
// TODO: update logic to lookup all payment attempts for an intent
// and apply filter logic on top of them to get the desired one.
PaymentAttempt::find_by_merchant_id_connector_txn_id( PaymentAttempt::find_by_merchant_id_connector_txn_id(
&conn, &conn,
merchant_id, merchant_id,

View File

@ -249,10 +249,7 @@ mod storage {
.into_report() .into_report()
} }
enums::MerchantStorageScheme::RedisKv => { enums::MerchantStorageScheme::RedisKv => Err(errors::StorageError::KVError.into()),
//TODO: Implement this
Err(errors::StorageError::KVError.into())
}
} }
} }
} }
@ -333,7 +330,8 @@ impl PaymentIntentInterface for MockDb {
_pc: &api::PaymentListConstraints, _pc: &api::PaymentListConstraints,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<Vec<types::PaymentIntent>, errors::StorageError> { ) -> CustomResult<Vec<types::PaymentIntent>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
#[allow(clippy::panic)] #[allow(clippy::panic)]
@ -372,6 +370,8 @@ impl PaymentIntentInterface for MockDb {
Ok(payment_intent) Ok(payment_intent)
} }
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn update_payment_intent( async fn update_payment_intent(
&self, &self,
this: types::PaymentIntent, this: types::PaymentIntent,
@ -387,6 +387,8 @@ impl PaymentIntentInterface for MockDb {
Ok(payment_intent.clone()) Ok(payment_intent.clone())
} }
// safety: only used for testing
#[allow(clippy::unwrap_used)]
async fn find_payment_intent_by_payment_id_merchant_id( async fn find_payment_intent_by_payment_id_merchant_id(
&self, &self,
payment_id: &str, payment_id: &str,

View File

@ -88,14 +88,16 @@ impl PaymentMethodInterface for MockDb {
&self, &self,
_payment_method_id: &str, _payment_method_id: &str,
) -> CustomResult<storage::PaymentMethod, errors::StorageError> { ) -> CustomResult<storage::PaymentMethod, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_payment_method( async fn insert_payment_method(
&self, &self,
_m: storage::PaymentMethodNew, _m: storage::PaymentMethodNew,
) -> CustomResult<storage::PaymentMethod, errors::StorageError> { ) -> CustomResult<storage::PaymentMethod, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_payment_method_by_customer_id_merchant_id_list( async fn find_payment_method_by_customer_id_merchant_id_list(
@ -103,7 +105,8 @@ impl PaymentMethodInterface for MockDb {
_customer_id: &str, _customer_id: &str,
_merchant_id: &str, _merchant_id: &str,
) -> CustomResult<Vec<storage::PaymentMethod>, errors::StorageError> { ) -> CustomResult<Vec<storage::PaymentMethod>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn delete_payment_method_by_merchant_id_payment_method_id( async fn delete_payment_method_by_merchant_id_payment_method_id(
@ -111,6 +114,7 @@ impl PaymentMethodInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_payment_method_id: &str, _payment_method_id: &str,
) -> CustomResult<storage::PaymentMethod, errors::StorageError> { ) -> CustomResult<storage::PaymentMethod, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -167,7 +167,8 @@ impl ProcessTrackerInterface for MockDb {
_ids: Vec<String>, _ids: Vec<String>,
_schedule_time: PrimitiveDateTime, _schedule_time: PrimitiveDateTime,
) -> CustomResult<usize, errors::StorageError> { ) -> CustomResult<usize, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_processes_by_time_status( async fn find_processes_by_time_status(
@ -177,7 +178,8 @@ impl ProcessTrackerInterface for MockDb {
_status: enums::ProcessTrackerStatus, _status: enums::ProcessTrackerStatus,
_limit: Option<i64>, _limit: Option<i64>,
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> { ) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_process( async fn insert_process(
@ -209,7 +211,8 @@ impl ProcessTrackerInterface for MockDb {
_this: storage::ProcessTracker, _this: storage::ProcessTracker,
_process: storage::ProcessTrackerUpdate, _process: storage::ProcessTrackerUpdate,
) -> CustomResult<storage::ProcessTracker, errors::StorageError> { ) -> CustomResult<storage::ProcessTracker, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn update_process_tracker( async fn update_process_tracker(
@ -217,7 +220,8 @@ impl ProcessTrackerInterface for MockDb {
_this: storage::ProcessTracker, _this: storage::ProcessTracker,
_process: storage::ProcessTrackerUpdate, _process: storage::ProcessTrackerUpdate,
) -> CustomResult<storage::ProcessTracker, errors::StorageError> { ) -> CustomResult<storage::ProcessTracker, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn process_tracker_update_process_status_by_ids( async fn process_tracker_update_process_status_by_ids(
@ -225,6 +229,7 @@ impl ProcessTrackerInterface for MockDb {
_task_ids: Vec<String>, _task_ids: Vec<String>,
_task_update: storage::ProcessTrackerUpdate, _task_update: storage::ProcessTrackerUpdate,
) -> CustomResult<usize, errors::StorageError> { ) -> CustomResult<usize, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -126,7 +126,10 @@ impl QueueInterface for MockDb {
_group_name: &str, _group_name: &str,
_consumer_name: &str, _consumer_name: &str,
) -> CustomResult<Vec<storage::ProcessTracker>, ProcessTrackerError> { ) -> CustomResult<Vec<storage::ProcessTracker>, ProcessTrackerError> {
todo!() // [#172]: Implement function for `MockDb`
Err(ProcessTrackerError::ResourceFetchingFailed {
resource_name: "consumer_tasks".to_string(),
})?
} }
async fn consumer_group_create( async fn consumer_group_create(
@ -135,7 +138,8 @@ impl QueueInterface for MockDb {
_group: &str, _group: &str,
_id: &RedisEntryId, _id: &RedisEntryId,
) -> CustomResult<(), RedisError> { ) -> CustomResult<(), RedisError> {
todo!() // [#172]: Implement function for `MockDb`
Err(RedisError::ConsumerGroupCreateFailed)?
} }
async fn acquire_pt_lock( async fn acquire_pt_lock(
@ -145,11 +149,13 @@ impl QueueInterface for MockDb {
_lock_val: &str, _lock_val: &str,
_ttl: i64, _ttl: i64,
) -> bool { ) -> bool {
todo!() // [#172]: Implement function for `MockDb`
false
} }
async fn release_pt_lock(&self, _tag: &str, _lock_key: &str) -> bool { async fn release_pt_lock(&self, _tag: &str, _lock_key: &str) -> bool {
todo!() // [#172]: Implement function for `MockDb`
false
} }
async fn stream_append_entry( async fn stream_append_entry(
@ -158,7 +164,8 @@ impl QueueInterface for MockDb {
_entry_id: &RedisEntryId, _entry_id: &RedisEntryId,
_fields: Vec<(&str, String)>, _fields: Vec<(&str, String)>,
) -> CustomResult<(), RedisError> { ) -> CustomResult<(), RedisError> {
todo!() // [#172]: Implement function for `MockDb`
Err(RedisError::StreamAppendFailed)?
} }
async fn get_key(&self, key: &str) -> CustomResult<Vec<u8>, RedisError> { async fn get_key(&self, key: &str) -> CustomResult<Vec<u8>, RedisError> {

View File

@ -553,7 +553,8 @@ impl RefundInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<storage_types::Refund, errors::StorageError> { ) -> CustomResult<storage_types::Refund, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_refund( async fn insert_refund(
@ -614,7 +615,8 @@ impl RefundInterface for MockDb {
_refund: storage_types::RefundUpdate, _refund: storage_types::RefundUpdate,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<storage_types::Refund, errors::StorageError> { ) -> CustomResult<storage_types::Refund, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_refund_by_merchant_id_refund_id( async fn find_refund_by_merchant_id_refund_id(
@ -642,6 +644,7 @@ impl RefundInterface for MockDb {
_merchant_id: &str, _merchant_id: &str,
_storage_scheme: enums::MerchantStorageScheme, _storage_scheme: enums::MerchantStorageScheme,
) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> { ) -> CustomResult<Vec<storage_types::Refund>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -100,20 +100,23 @@ impl TempCardInterface for MockDb {
&self, &self,
_transaction_id: &str, _transaction_id: &str,
) -> CustomResult<Option<storage::TempCard>, errors::StorageError> { ) -> CustomResult<Option<storage::TempCard>, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn insert_tempcard_with_token( async fn insert_tempcard_with_token(
&self, &self,
_card: storage::TempCard, _card: storage::TempCard,
) -> CustomResult<storage::TempCard, errors::StorageError> { ) -> CustomResult<storage::TempCard, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
async fn find_tempcard_by_token( async fn find_tempcard_by_token(
&self, &self,
_token: &i32, _token: &i32,
) -> CustomResult<storage::TempCard, errors::StorageError> { ) -> CustomResult<storage::TempCard, errors::StorageError> {
todo!() // [#172]: Implement function for `MockDb`
Err(errors::StorageError::MockDbError)?
} }
} }

View File

@ -13,8 +13,10 @@
clippy::panic, clippy::panic,
clippy::panic_in_result_fn, clippy::panic_in_result_fn,
clippy::panicking_unwrap, clippy::panicking_unwrap,
clippy::todo,
clippy::unreachable, clippy::unreachable,
clippy::unwrap_in_result, clippy::unwrap_in_result,
clippy::unwrap_used
)] )]
#![recursion_limit = "256"] #![recursion_limit = "256"]

View File

@ -158,6 +158,7 @@ pub async fn payment_method_delete_api(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#![allow(clippy::unwrap_used)]
use api_models::payment_methods::ListPaymentMethodRequest; use api_models::payment_methods::ListPaymentMethodRequest;
use super::*; use super::*;

View File

@ -76,6 +76,7 @@ pub trait ProcessTrackerWorkflow: Send + Sync {
#[cfg(test)] #[cfg(test)]
mod workflow_tests { mod workflow_tests {
#![allow(clippy::unwrap_used)]
use super::PTRunner; use super::PTRunner;
use crate::utils::StringExt; use crate::utils::StringExt;

View File

@ -178,7 +178,7 @@ pub trait Payment:
#[cfg(test)] #[cfg(test)]
mod payments_test { mod payments_test {
#![allow(clippy::expect_used)] #![allow(clippy::expect_used, clippy::unwrap_used)]
use super::*; use super::*;