diff --git a/rustv1/examples/cloudwatchlogs/Cargo.toml b/rustv1/examples/cloudwatchlogs/Cargo.toml index b81c82de7ab..574c3d9759e 100644 --- a/rustv1/examples/cloudwatchlogs/Cargo.toml +++ b/rustv1/examples/cloudwatchlogs/Cargo.toml @@ -25,5 +25,4 @@ sdk-examples-test-utils = { path = "../../test-utils" } futures = "0.3.30" [dev-dependencies] -aws-smithy-mocks-experimental = "0.1.0" -# aws-smithy-runtime = { version="1", features = ["test-util"] } +aws-smithy-mocks-experimental = "0.2.0" diff --git a/rustv1/examples/cloudwatchlogs/src/bin/large-query.rs b/rustv1/examples/cloudwatchlogs/src/bin/large-query.rs index 47b4e591be1..8635adf4b50 100644 --- a/rustv1/examples/cloudwatchlogs/src/bin/large-query.rs +++ b/rustv1/examples/cloudwatchlogs/src/bin/large-query.rs @@ -236,28 +236,10 @@ async fn main() -> Result<(), LargeQueryError> { #[cfg(test)] mod test { use super::*; - use aws_config::Region; - use aws_sdk_cloudwatchlogs::{operation::start_query::StartQueryOutput, Config}; - use aws_smithy_mocks_experimental::{mock, MockResponseInterceptor, Rule}; + use aws_sdk_cloudwatchlogs::operation::start_query::StartQueryOutput; + use aws_smithy_mocks_experimental::{make_client, mock, RuleMode}; use chrono::{TimeZone, Utc}; - fn client_from_rules(rules: &[&Rule], enforce_order: bool) -> Client { - let mut mock_response_interceptor = MockResponseInterceptor::new(); - for rule in rules { - mock_response_interceptor = mock_response_interceptor.with_rule(rule) - } - if enforce_order { - mock_response_interceptor = mock_response_interceptor.enforce_order(); - } - Client::from_conf( - Config::builder() - .with_test_defaults() - .region(Region::from_static("us-east-1")) - .interceptor(mock_response_interceptor) - .build(), - ) - } - // Test the behavior of the DateRange::split function. #[tokio::test] async fn test_date_range_split() { @@ -333,7 +315,7 @@ mod test { .build() }); - let client = client_from_rules(&[&start_query, &small_result], false); + let client = make_client!(aws_sdk_cloudwatchlogs, &[&start_query, &small_result]); let query = CloudWatchLongQuery::new(client, "testing".into(), date_range.clone()); // Act: Invoke the large_query method with this range. @@ -388,7 +370,11 @@ mod test { .build() }); - let client = client_from_rules(&[&get_query_results_0, &get_query_results_1], true); + let client = make_client!( + aws_sdk_cloudwatchlogs, + RuleMode::Sequential, + &[&get_query_results_0, &get_query_results_1] + ); // Arrange: Mock different responses from CloudWatch Logs with varying statuses. let query = CloudWatchLongQuery::new(client, "testing".into(), date_range.clone());