From a339f6bcd31bb7cef31cf98e3c3aef49a3e0d65a Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 13 Mar 2023 15:21:19 -0500 Subject: [PATCH] Fix test failure in `no-default-features` (#2450) * Fix test failure in `no-default-features` This commit fixes a test failure from `test_clients_from_sdk_config`. It is a negative test expecting a panic, but it failed because it panicked for a different reason, i.e. "no default sleep implementation available." * Avoid bringing in `rt-tokio` for `aws-smithy-async` This commit addresses https://github.com/awslabs/smithy-rs/pull/2450#discussion_r1134426351. --------- Co-authored-by: Yuki Saito --- .../no-default-features/Cargo.toml | 1 + .../tests/client-construction.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/aws/sdk/integration-tests/no-default-features/Cargo.toml b/aws/sdk/integration-tests/no-default-features/Cargo.toml index bb0ba9d02..ba0f49735 100644 --- a/aws/sdk/integration-tests/no-default-features/Cargo.toml +++ b/aws/sdk/integration-tests/no-default-features/Cargo.toml @@ -16,6 +16,7 @@ publish = false [dev-dependencies] aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false } aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false } +aws-smithy-async = { path = "../../build/aws-sdk/sdk/aws-smithy-async" } futures = "0.3.25" tokio = { version = "1.8.4", features = ["full", "test-util"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/aws/sdk/integration-tests/no-default-features/tests/client-construction.rs b/aws/sdk/integration-tests/no-default-features/tests/client-construction.rs index 1a602dc98..8f250f932 100644 --- a/aws/sdk/integration-tests/no-default-features/tests/client-construction.rs +++ b/aws/sdk/integration-tests/no-default-features/tests/client-construction.rs @@ -13,12 +13,22 @@ async fn test_clients_from_sdk_config() { } // This will fail due to lack of a connector when constructing the service client -#[test] +#[tokio::test] #[should_panic( expected = "No HTTP connector was available. Enable the `rustls` or `native-tls` crate feature or set a connector to fix this." )] -fn test_clients_from_service_config() { - let config = aws_sdk_s3::Config::builder().build(); +async fn test_clients_from_service_config() { + #[derive(Clone, Debug)] + struct StubSleep; + impl aws_smithy_async::rt::sleep::AsyncSleep for StubSleep { + fn sleep(&self, _duration: std::time::Duration) -> aws_sdk_s3::config::Sleep { + todo!() + } + } + + let config = aws_sdk_s3::Config::builder() + .sleep_impl(std::sync::Arc::new(StubSleep {})) + .build(); // This will panic due to the lack of an HTTP connector aws_sdk_s3::Client::from_conf(config); } -- GitLab