in sdk/eventhubs/azure_messaging_eventhubs/src/common/management.rs [235:323]
fn should_retry_management_response() {
consumer::tests::setup();
{
let error: azure_core::Error = AmqpError::new_management_error(
azure_core::http::StatusCode::TooManyRequests,
Some("Too many requests!".into()),
)
.into();
assert!(ManagementInstance::should_retry_management_response(&error));
}
{
let error: azure_core::Error = AmqpError::new_management_error(
azure_core::http::StatusCode::SwitchingProtocols,
Some("Switcheroo".into()),
)
.into();
assert!(!ManagementInstance::should_retry_management_response(
&error
));
}
// Verify that an explicitly boxed error is handled correctly
{
let error = azure_core::Error::new(
AzureErrorKind::Amqp,
Box::new(AmqpError::new_management_error(
azure_core::http::StatusCode::TooManyRequests,
Some("Too many requests!".into()),
)),
);
assert!(ManagementInstance::should_retry_management_response(&error));
}
{
let error: azure_core::Error = AmqpError::new_management_error(
azure_core::http::StatusCode::BadGateway,
Some("Bad Gateway".into()),
)
.into();
assert!(ManagementInstance::should_retry_management_response(&error));
}
{
let error: azure_core::Error = AmqpError::new_management_error(
azure_core::http::StatusCode::RequestTimeout,
Some("Request Timeout".into()),
)
.into();
assert!(ManagementInstance::should_retry_management_response(&error));
}
{
let error: azure_core::Error = AmqpError::new_management_error(
azure_core::http::StatusCode::InternalServerError,
Some("Internal Server Error".into()),
)
.into();
assert!(ManagementInstance::should_retry_management_response(&error));
{
let error: azure_core::Error =
EventHubsError::from(ErrorKind::InvalidManagementResponse).into();
assert!(!ManagementInstance::should_retry_management_response(
&error
));
}
{
let error: azure_core::Error = AmqpError::new_described_error(
AmqpErrorCondition::ResourceLimitExceeded,
Some("Resource Limit Exceeded".into()),
Default::default(),
)
.into();
assert!(ManagementInstance::should_retry_management_response(&error));
}
{
let error: azure_core::Error = AmqpError::new_described_error(
AmqpErrorCondition::IllegalState,
Some("Illegal State".into()),
Default::default(),
)
.into();
assert!(!ManagementInstance::should_retry_management_response(
&error
));
}
}
}