-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathclient_construction.rs
More file actions
81 lines (71 loc) · 3 KB
/
client_construction.rs
File metadata and controls
81 lines (71 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
mod with_sdk_config {
use aws_config::SdkConfig;
use aws_sdk_s3 as s3;
use s3::config::StalledStreamProtectionConfig;
#[tokio::test]
async fn using_config_loader() {
// When using `aws_config::load_from_env`, things should just work
let config = aws_config::load_from_env().await;
assert!(config.timeout_config().unwrap().has_timeouts());
assert!(config.retry_config().unwrap().has_retry());
let _s3 = s3::Client::new(&config);
}
#[test]
fn manual_config_construction_all_defaults() {
// When manually constructing `SdkConfig` with everything unset,
// it should work since there will be no timeouts or retries enabled,
// and thus, no sleep impl is required.
let config = SdkConfig::builder()
.stalled_stream_protection(StalledStreamProtectionConfig::disabled())
.build();
assert!(config.timeout_config().is_none());
assert!(config.retry_config().is_none());
let _s3 = s3::Client::new(&config);
}
#[test]
fn bytestream_from_path_exists() {
let _ = aws_sdk_s3::primitives::ByteStream::from_path("a/b.txt");
}
}
mod with_service_config {
use aws_sdk_s3 as s3;
use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
#[test]
fn manual_config_construction_all_defaults() {
// When manually constructing `Config` with everything unset,
// it should work since there will be no timeouts or retries enabled,
// and thus, no sleep impl is required.
let config = s3::Config::builder().build();
let _s3 = s3::Client::from_conf(config);
}
#[test]
#[allow(deprecated)]
fn test_client_with_new_behavior_version_builds_successfully() {
// With v2025_01_17, retries are enabled by default
// This test verifies the client builds without panicking about missing sleep impl
let config = s3::Config::builder()
.behavior_version(BehaviorVersion::v2025_01_17())
.region(aws_types::region::Region::new("us-east-1"))
.credentials_provider(aws_credential_types::Credentials::for_tests())
.build();
// Should build successfully even though retries are enabled
// (sleep impl is provided by default)
let _client = s3::Client::from_conf(config);
}
#[test]
#[allow(deprecated)]
fn test_client_with_old_behavior_version_builds_successfully() {
// With v2024_03_28, retries are disabled by default
let config = s3::Config::builder()
.behavior_version(BehaviorVersion::v2024_03_28())
.region(aws_types::region::Region::new("us-east-1"))
.credentials_provider(aws_credential_types::Credentials::for_tests())
.build();
// Should build successfully with retries disabled
let _client = s3::Client::from_conf(config);
}
}