File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,44 @@ mod tests {
293
293
}
294
294
}
295
295
296
+ // Create a mock client that returns a specific status code and empty
297
+ // response body.
298
+ fn mock_client_with_status ( status : u16 ) -> Client {
299
+ let dispatcher = MockRequestDispatcher :: with_status ( status) ;
300
+
301
+ let client = S3Client :: new_with (
302
+ dispatcher,
303
+ MockCredentialsProvider ,
304
+ Default :: default ( )
305
+ ) ;
306
+
307
+ Client {
308
+ client : client,
309
+ bucket_name : None ,
310
+ object_versions : ObjectVersions :: Current ,
311
+ region : Region :: UsEast1 ,
312
+ }
313
+ }
314
+
315
+ #[ tokio:: test]
316
+ async fn test_head_bucket ( ) {
317
+ let tests = vec ! [
318
+ ( 200 , true ) ,
319
+ ( 403 , false ) ,
320
+ ( 404 , false ) ,
321
+ ] ;
322
+
323
+ for test in tests {
324
+ let status_code: u16 = test. 0 ;
325
+ let expected = test. 1 ;
326
+
327
+ let client = mock_client_with_status ( status_code) ;
328
+ let ret = Client :: head_bucket ( & client, "test-bucket" ) . await ;
329
+
330
+ assert_eq ! ( ret, expected) ;
331
+ }
332
+ }
333
+
296
334
#[ tokio:: test]
297
335
async fn test_get_bucket_location_err ( ) {
298
336
let client = mock_client (
You can’t perform that action at this time.
0 commit comments