/// Loads a mock fixture into the S3 bucket if it does not exist.
Loads a mock fixture into the S3 bucket if it does not exist.
Loads a mock fixture into the S3 bucket if it does not exist .
async fn ensure_fixture(
        s3_client: &S3Client,
        fixture: impl AsRef<Path>,
        key: impl Into<String>,
    ) {
        let key = key.into();
        let head_result = s3_client
            .head_object(rusoto_s3::HeadObjectRequest {
                bucket: S3_BUCKET.to_owned(),
                key: key.clone(),
                ..Default::default()
            })
            .await;
        match head_result {
            Ok(_) => return,
            Err(rusoto_core::RusotoError::Service(rusoto_s3::HeadObjectError::NoSuchKey(_))) => {
                // fallthrough
            }
            Err(err) => panic!("failed to check S3 object: {:?}", err),
        }
        s3_client
            .put_object(rusoto_s3::PutObjectRequest {
                bucket: S3_BUCKET.to_owned(),
                body: Some(test::read_fixture(fixture).into()),
                key,
                ..Default::default()
            })
            .await
            .unwrap();
    }
async fn ensure_fixture ( s3_client : & S3Client , fixture : impl AsRef < Path > , key : impl Into < String > , ) { let key = key . into ( ) ; let head_result = s3_client . head_object ( rusoto_s3 :: HeadObjectRequest { bucket : S3_BUCKET . to_owned ( ) , key : key . clone ( ) , .. Default :: default ( ) } ) . await ; match head_result { Ok ( _ ) => return , Err ( rusoto_core :: RusotoError :: Service ( rusoto_s3 :: HeadObjectError :: NoSuchKey ( _ ) ) ) => { // fallthrough } Err ( err ) => panic ! ( " " err ) , } s3_client . put_object ( rusoto_s3 :: PutObjectRequest { bucket : S3_BUCKET . to_owned ( ) , body : Some ( test :: read_fixture ( fixture ) . into ( ) ) , key , .. Default :: default ( ) } ) . await . unwrap ( ) ; }
Loads a mock fixture into the S3 bucket if it does not exist.
Loads a mock fixture into the S3 bucket if it does not exist .
s3_client
&S3Client
fixture
impl AsRef<Path>
key
impl Into<String>