Skip to content

Commit

Permalink
tests(behavior): add test for write overwrite
Browse files Browse the repository at this point in the history
Signed-off-by: Hanchin Hsieh <[email protected]>
  • Loading branch information
yuchanns committed Jun 27, 2024
1 parent 0ebb425 commit bfc3fa4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions core/tests/behavior/async_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub fn tests(op: &Operator, tests: &mut Vec<Trial>) {
test_write_with_content_type,
test_write_with_content_disposition,
test_writer_write,
test_writer_write_overwrite,
test_writer_write_with_concurrent,
test_writer_sink,
test_writer_sink_with_concurrent,
Expand Down Expand Up @@ -561,3 +562,34 @@ pub async fn test_writer_with_append(op: Operator) -> Result<()> {
op.delete(&path).await.expect("delete must succeed");
Ok(())
}

pub async fn test_writer_write_overwrite(op: Operator) -> Result<()> {
let path = uuid::Uuid::new_v4().to_string();
let (content_one, _) = gen_bytes(op.info().full_capability());
let (content_two, _) = gen_bytes(op.info().full_capability());

op.write(&path, content_one.clone()).await?;
let bs = op.read(&path).await?.to_bytes();
assert_eq!(
format!("{:x}", Sha256::digest(&bs)),
format!("{:x}", Sha256::digest(&content_one)),
"read content_one"
);
op.write(&path, content_two.clone())
.await
.expect("write overwrite must succeed");
let bs = op.read(&path).await?.to_bytes();
assert_ne!(
format!("{:x}", Sha256::digest(&bs)),
format!("{:x}", Sha256::digest(&content_one)),
"content_one must be overwrited"

Check warning on line 585 in core/tests/behavior/async_write.rs

View workflow job for this annotation

GitHub Actions / typos

"overwrited" should be "overwritten" or "overwrote".
);
assert_eq!(
format!("{:x}", Sha256::digest(&bs)),
format!("{:x}", Sha256::digest(&content_two)),
"read content_two"
);

op.delete(&path).await.expect("delete must succeed");
Ok(())
}

0 comments on commit bfc3fa4

Please sign in to comment.