Skip to content

Commit 339b633

Browse files
joshtriplettFishrock123
authored andcommitted
Add a test for Body::chain on Body instances after calling read
1 parent bcde50c commit 339b633

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/body.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,4 +771,30 @@ mod test {
771771

772772
Ok(())
773773
}
774+
775+
#[async_std::test]
776+
async fn chain_skip_start() -> crate::Result<()> {
777+
for buf_len in 1..26 {
778+
let mut body1 = Body::from_reader(Cursor::new("1234 hello xyz"), Some(11));
779+
let mut buf = vec![0; 5];
780+
body1.read(&mut buf).await?;
781+
assert_eq!(buf, b"1234 ");
782+
783+
let mut body2 = Body::from_reader(Cursor::new("321 world abc"), Some(9));
784+
let mut buf = vec![0; 4];
785+
body2.read(&mut buf).await?;
786+
assert_eq!(buf, b"321 ");
787+
788+
let mut body = body1.chain(body2);
789+
assert_eq!(body.len(), Some(11));
790+
assert_eq!(body.mime(), &mime::BYTE_STREAM);
791+
assert_eq!(
792+
read_with_buffers_of_size(&mut body, buf_len).await?,
793+
"hello world"
794+
);
795+
assert_eq!(body.bytes_read, 11);
796+
}
797+
798+
Ok(())
799+
}
774800
}

0 commit comments

Comments
 (0)