mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
chore: address Rust 1.75 clippy lints (#3231)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -1512,86 +1512,6 @@ pub fn get_error_code_error_message_based_on_priority(
|
||||
.cloned()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod error_code_error_message_tests {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
use super::*;
|
||||
|
||||
struct TestConnector;
|
||||
|
||||
impl ConnectorErrorTypeMapping for TestConnector {
|
||||
fn get_connector_error_type(
|
||||
&self,
|
||||
error_code: String,
|
||||
error_message: String,
|
||||
) -> ConnectorErrorType {
|
||||
match (error_code.as_str(), error_message.as_str()) {
|
||||
("01", "INVALID_MERCHANT") => ConnectorErrorType::BusinessError,
|
||||
("03", "INVALID_CVV") => ConnectorErrorType::UserError,
|
||||
("04", "04") => ConnectorErrorType::TechnicalError,
|
||||
_ => ConnectorErrorType::UnknownError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_error_code_error_message_based_on_priority() {
|
||||
let error_code_message_list_unknown = vec![
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "01".to_string(),
|
||||
error_message: "INVALID_MERCHANT".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "05".to_string(),
|
||||
error_message: "05".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "04".to_string(),
|
||||
error_message: "04".to_string(),
|
||||
},
|
||||
];
|
||||
let error_code_message_list_user = vec![
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "01".to_string(),
|
||||
error_message: "INVALID_MERCHANT".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
},
|
||||
];
|
||||
let error_code_error_message_unknown = get_error_code_error_message_based_on_priority(
|
||||
TestConnector,
|
||||
error_code_message_list_unknown,
|
||||
);
|
||||
let error_code_error_message_user = get_error_code_error_message_based_on_priority(
|
||||
TestConnector,
|
||||
error_code_message_list_user,
|
||||
);
|
||||
let error_code_error_message_none =
|
||||
get_error_code_error_message_based_on_priority(TestConnector, vec![]);
|
||||
assert_eq!(
|
||||
error_code_error_message_unknown,
|
||||
Some(ErrorCodeAndMessage {
|
||||
error_code: "05".to_string(),
|
||||
error_message: "05".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
error_code_error_message_user,
|
||||
Some(ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(error_code_error_message_none, None);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MultipleCaptureSyncResponse {
|
||||
fn get_connector_capture_id(&self) -> String;
|
||||
fn get_capture_attempt_status(&self) -> enums::AttemptStatus;
|
||||
@ -1785,3 +1705,83 @@ impl FrmTransactionRouterDataRequest for fraud_check::FrmTransactionRouterData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod error_code_error_message_tests {
|
||||
#![allow(clippy::unwrap_used)]
|
||||
use super::*;
|
||||
|
||||
struct TestConnector;
|
||||
|
||||
impl ConnectorErrorTypeMapping for TestConnector {
|
||||
fn get_connector_error_type(
|
||||
&self,
|
||||
error_code: String,
|
||||
error_message: String,
|
||||
) -> ConnectorErrorType {
|
||||
match (error_code.as_str(), error_message.as_str()) {
|
||||
("01", "INVALID_MERCHANT") => ConnectorErrorType::BusinessError,
|
||||
("03", "INVALID_CVV") => ConnectorErrorType::UserError,
|
||||
("04", "04") => ConnectorErrorType::TechnicalError,
|
||||
_ => ConnectorErrorType::UnknownError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_error_code_error_message_based_on_priority() {
|
||||
let error_code_message_list_unknown = vec![
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "01".to_string(),
|
||||
error_message: "INVALID_MERCHANT".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "05".to_string(),
|
||||
error_message: "05".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "04".to_string(),
|
||||
error_message: "04".to_string(),
|
||||
},
|
||||
];
|
||||
let error_code_message_list_user = vec![
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "01".to_string(),
|
||||
error_message: "INVALID_MERCHANT".to_string(),
|
||||
},
|
||||
ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
},
|
||||
];
|
||||
let error_code_error_message_unknown = get_error_code_error_message_based_on_priority(
|
||||
TestConnector,
|
||||
error_code_message_list_unknown,
|
||||
);
|
||||
let error_code_error_message_user = get_error_code_error_message_based_on_priority(
|
||||
TestConnector,
|
||||
error_code_message_list_user,
|
||||
);
|
||||
let error_code_error_message_none =
|
||||
get_error_code_error_message_based_on_priority(TestConnector, vec![]);
|
||||
assert_eq!(
|
||||
error_code_error_message_unknown,
|
||||
Some(ErrorCodeAndMessage {
|
||||
error_code: "05".to_string(),
|
||||
error_message: "05".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
error_code_error_message_user,
|
||||
Some(ErrorCodeAndMessage {
|
||||
error_code: "03".to_string(),
|
||||
error_message: "INVALID_CVV".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(error_code_error_message_none, None);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user