Skip to content

Commit

Permalink
Use RuleMode added in smithy-lang/smithy-rs#3502
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSouther committed Mar 28, 2024
1 parent 5fad395 commit ecd1b07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
3 changes: 1 addition & 2 deletions rustv1/examples/cloudwatchlogs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
30 changes: 8 additions & 22 deletions rustv1/examples/cloudwatchlogs/src/bin/large-query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit ecd1b07

Please sign in to comment.