meteorgan commented on code in PR #5500:
URL: https://github.com/apache/opendal/pull/5500#discussion_r1901846406
##########
core/tests/behavior/async_read.rs:
##########
@@ -270,6 +274,74 @@ pub async fn test_reader_with_if_none_match(op: Operator)
-> anyhow::Result<()>
Ok(())
}
+/// Reader with if_modified_since should match, otherwise, a ConditionNotMatch
error will be returned.
+pub async fn test_reader_with_if_modified_since(op: Operator) ->
anyhow::Result<()> {
+ if !op.info().full_capability().read_with_if_modified_since {
+ return Ok(());
+ }
+
+ let (path, content, _) = TEST_FIXTURE.new_file(op.clone());
+
+ op.write(&path, content.clone())
+ .await
+ .expect("write must succeed");
+
+ let one_hour_ago_check = chrono::Utc::now() -
chrono::Duration::seconds(3600);
+ let reader = op
+ .reader_with(&path)
+ .if_modified_since(one_hour_ago_check)
+ .await?;
+ let bs = reader.read(..).await?.to_bytes();
+ assert_eq!(bs, content);
+
+ sleep(Duration::from_secs(3)).await;
+
+ let one_second_ago_check = chrono::Utc::now() -
chrono::Duration::seconds(1);
Review Comment:
Maybe We can just use `chrono::Utc::now()` here. but I'm not sure if this
test will remain stable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]