Skip to content

Commit

Permalink
test: improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-III committed Nov 27, 2024
1 parent a302650 commit 5ee6881
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions core/tests/behavior/async_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,23 @@ pub async fn test_write_with_if_match(op: Operator) -> Result<()> {
}

let (path, content, _) = TEST_FIXTURE.new_file(op.clone());
let (path_incorrect, _, _) = TEST_FIXTURE.new_file(op.clone());

op.write(&path, content.clone()).await?;
op.write(&path_incorrect, content.clone()).await?;

let meta = op.stat(&path).await?;
let etag = meta.etag().expect("etag must exist");

let res = op.write_with(&path, content.clone()).if_match(etag).await;
assert!(res.is_ok());

let res = op
.write_with(&path_incorrect, content.clone())
.if_match(etag)
.await;
assert!(res.is_err());
assert_eq!(res.unwrap_err().kind(), ErrorKind::ConditionNotMatch);

Ok(())
}

0 comments on commit 5ee6881

Please sign in to comment.