pub async fn parcel_fixture(content: &str) -> (crate::Label, tokio::fs::File) {
    let data = tempfile::tempfile().unwrap();
    let sha = format!("{:x}", Sha256::digest(content.as_bytes()));
    let mut data = File::from_std(data);
    data.write_all(content.as_bytes())
        .await
        .expect("unable to write test data");
    data.flush().await.expect("unable to flush the test file");
    data.seek(SeekFrom::Start(0))
        .await
        .expect("unable to reset read pointer to head");
    (
        crate::Label {
            sha256: sha.to_owned(),
            media_type: "text/toml".to_owned(),
            name: "foo.toml".to_owned(),
            size: 6,
            ..Default::default()
        },
        data,
    )
}
/// Creates a fake parcel in memory using the given content for use in testing
Creates a fake parcel in memory using the given content for use in testing
Creates a fake parcel in memory using the given content for use in testing
pub async fn parcel_fixture(content: &str) -> (crate::Label, tokio::fs::File) {
    let data = tempfile::tempfile().unwrap();
    let sha = format!("{:x}", Sha256::digest(content.as_bytes()));
    let mut data = File::from_std(data);
    data.write_all(content.as_bytes())
        .await
        .expect("unable to write test data");
    data.flush().await.expect("unable to flush the test file");
    data.seek(SeekFrom::Start(0))
        .await
        .expect("unable to reset read pointer to head");
    (
        crate::Label {
            sha256: sha.to_owned(),
            media_type: "text/toml".to_owned(),
            name: "foo.toml".to_owned(),
            size: 6,
            ..Default::default()
        },
        data,
    )
}
pub async fn parcel_fixture ( content : & str ) -> ( crate :: Label , tokio :: fs :: File ) { let data = tempfile :: tempfile ( ) . unwrap ( ) ; let sha = format ! ( " " Sha256 digest ( content as_bytes ( ) ) ) ; let mut data = File :: from_std ( data ) ; data . write_all ( content . as_bytes ( ) ) . await . expect ( " " ) ; data . flush ( ) . await . expect ( " " ) ; data . seek ( SeekFrom :: Start ( 0 ) ) . await . expect ( " " ) ; ( crate :: Label { sha256 : sha . to_owned ( ) , media_type : " " . to_owned ( ) , name : " " . to_owned ( ) , size : 6 , .. Default :: default ( ) } , data , ) }
Creates a fake parcel in memory using the given content for use in testing
Creates a fake parcel in memory using the given content for use in testing
content
&str
content
&str