3
3
* SPDX-License-Identifier: Apache-2.0.
4
4
*/
5
5
6
+ // snippet-start:[testing.rust.replay-uses]
6
7
use aws_sdk_s3 as s3;
8
+ // snippet-end:[testing.rust.replay-uses]
7
9
8
10
#[ allow( dead_code) ]
9
11
// snippet-start:[testing.rust.replay]
@@ -42,6 +44,7 @@ pub async fn determine_prefix_file_size(
42
44
43
45
#[ allow( dead_code) ]
44
46
// snippet-start:[testing.rust.replay-tests]
47
+ // snippet-start:[testing.rust.replay-make-credentials]
45
48
fn make_s3_test_credentials ( ) -> s3:: config:: Credentials {
46
49
s3:: config:: Credentials :: new (
47
50
"ATESTCLIENT" ,
@@ -51,9 +54,12 @@ fn make_s3_test_credentials() -> s3::config::Credentials {
51
54
"" ,
52
55
)
53
56
}
57
+ // snippet-end:[testing.rust.replay-make-credentials]
54
58
59
+ // snippet-start:[testing.rust.replay-test-module]
55
60
#[ cfg( test) ]
56
61
mod test {
62
+ // snippet-start:[testing.rust.replay-test-single]
57
63
use super :: * ;
58
64
use aws_sdk_s3 as s3;
59
65
use aws_smithy_runtime:: client:: http:: test_util:: { ReplayEvent , StaticReplayClient } ;
@@ -90,9 +96,12 @@ mod test {
90
96
assert_eq ! ( 7 , size) ;
91
97
replay_client. assert_requests_match ( & [ ] ) ;
92
98
}
99
+ // snippet-end:[testing.rust.replay-test-single]
93
100
101
+ // snippet-start:[testing.rust.replay-test-multiple]
94
102
#[ tokio:: test]
95
103
async fn test_multiple_pages ( ) {
104
+ // snippet-start:[testing.rust.replay-create-replay]
96
105
let page_1 = ReplayEvent :: new (
97
106
http:: Request :: builder ( )
98
107
. method ( "GET" )
@@ -116,22 +125,29 @@ mod test {
116
125
. unwrap ( ) ,
117
126
) ;
118
127
let replay_client = StaticReplayClient :: new ( vec ! [ page_1, page_2] ) ;
128
+ // snippet-end:[testing.rust.replay-create-replay]
129
+ // snippet-start:[testing.rust.replay-create-client]
119
130
let client: s3:: Client = s3:: Client :: from_conf (
120
131
s3:: Config :: builder ( )
121
132
. credentials_provider ( make_s3_test_credentials ( ) )
122
133
. region ( s3:: config:: Region :: new ( "us-east-1" ) )
123
134
. http_client ( replay_client. clone ( ) )
124
135
. build ( ) ,
125
136
) ;
137
+ // snippet-end:[testing.rust.replay-create-client]
126
138
127
139
// Run the code we want to test with it
140
+ // snippet-start:[testing.rust.replay-test-and-verify]
128
141
let size = determine_prefix_file_size ( client, "test-bucket" , "test-prefix" )
129
142
. await
130
143
. unwrap ( ) ;
131
144
132
145
assert_eq ! ( 19 , size) ;
133
146
134
147
replay_client. assert_requests_match ( & [ ] ) ;
148
+ // snippet-end:[testing.rust.replay-test-and-verify]
135
149
}
136
- // snippet-end:[testing.rust.replay-tests ]
150
+ // snippet-end:[testing.rust.replay-test-multiple ]
137
151
}
152
+ // snippet-end:[testing.rust.replay-tests]
153
+ // snippet-end:[testing.rust.replay-test-module]
0 commit comments