mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
fix(scheduler): fix retry_count bug for getting schedule time (#6)
This commit is contained in:
@ -101,7 +101,7 @@ pub async fn get_sync_process_schedule_time(
|
||||
Ok(x) => x,
|
||||
Err(_) => process_data::ConnectorPTMapping::default(),
|
||||
};
|
||||
let time_delta = get_sync_schedule_time(mapping, merchant_id, retry_count + 1);
|
||||
let time_delta = get_sync_schedule_time(mapping, merchant_id, retry_count);
|
||||
|
||||
Ok(pt_utils::get_time_from_delta(time_delta))
|
||||
}
|
||||
@ -151,7 +151,7 @@ pub async fn retry_sync_task(
|
||||
pt: storage::ProcessTracker,
|
||||
) -> Result<(), errors::ProcessTrackerError> {
|
||||
let schedule_time =
|
||||
get_sync_process_schedule_time(&connector, &merchant_id, redis_conn, pt.retry_count)
|
||||
get_sync_process_schedule_time(&connector, &merchant_id, redis_conn, pt.retry_count + 1)
|
||||
.await?;
|
||||
|
||||
match schedule_time {
|
||||
@ -162,3 +162,22 @@ pub async fn retry_sync_task(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(clippy::expect_used, clippy::unwrap_used)]
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_get_default_schedule_time() {
|
||||
let schedule_time_delta =
|
||||
get_sync_schedule_time(process_data::ConnectorPTMapping::default(), "-", 0).unwrap();
|
||||
let first_retry_time_delta =
|
||||
get_sync_schedule_time(process_data::ConnectorPTMapping::default(), "-", 1).unwrap();
|
||||
let cpt_default = process_data::ConnectorPTMapping::default().default_mapping;
|
||||
assert_eq!(
|
||||
vec![schedule_time_delta, first_retry_time_delta],
|
||||
vec![cpt_default.start_after, cpt_default.frequency[0]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,6 @@ impl Default for PaymentMethod {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum PaymentIdType {
|
||||
PaymentIntentId(String),
|
||||
ConnectorTransactionId(String),
|
||||
@ -669,4 +668,13 @@ mod payments_test {
|
||||
serde_json::from_str(&serialized).expect("error de-serializing payments response");
|
||||
//assert_eq!(pay_req, deserialized_pay_req)
|
||||
}
|
||||
|
||||
// Intended to test the serialization and deserialization of the enum PaymentIdType
|
||||
#[test]
|
||||
fn test_connector_id_type() {
|
||||
let sample_1 = PaymentIdType::PaymentIntentId("test_234565430uolsjdnf48i0".to_string());
|
||||
let s_sample_1 = serde_json::to_string(&sample_1).unwrap();
|
||||
let ds_sample_1 = serde_json::from_str::<PaymentIdType>(&s_sample_1).unwrap();
|
||||
assert_eq!(ds_sample_1, sample_1)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user