Xuanwo commented on code in PR #2644:
URL:
https://github.com/apache/incubator-opendal/pull/2644#discussion_r1263530650
##########
core/tests/behavior/write.rs:
##########
@@ -1233,3 +1234,31 @@ pub async fn test_fuzz_unsized_writer(op: Operator) ->
Result<()> {
op.delete(&path).await.expect("delete must succeed");
Ok(())
}
+
+/// seeking a negative position should return a InvalidInput error
+pub async fn test_invalid_reader_seek(op: Operator) -> Result<()> {
+ let path = uuid::Uuid::new_v4().to_string();
+ debug!("Generate a random file: {}", &path);
+ let (content, _) = gen_bytes();
+
+ op.write(&path, content.clone())
+ .await
+ .expect("write must succeed");
+
+ let mut r = op.reader(&path).await?;
+ let res = r.seek(std::io::SeekFrom::Current(-1024)).await;
+
+ assert!(res.is_err());
Review Comment:
Please check if returing's error kind is `InvalidInput`.
##########
core/tests/behavior/write.rs:
##########
@@ -1233,3 +1234,31 @@ pub async fn test_fuzz_unsized_writer(op: Operator) ->
Result<()> {
op.delete(&path).await.expect("delete must succeed");
Ok(())
}
+
+/// seeking a negative position should return a InvalidInput error
+pub async fn test_invalid_reader_seek(op: Operator) -> Result<()> {
+ let path = uuid::Uuid::new_v4().to_string();
+ debug!("Generate a random file: {}", &path);
+ let (content, _) = gen_bytes();
+
+ op.write(&path, content.clone())
+ .await
+ .expect("write must succeed");
+
+ let mut r = op.reader(&path).await?;
+ let res = r.seek(std::io::SeekFrom::Current(-1024)).await;
+
+ assert!(res.is_err());
+
+ // the res should be a std::io::Error, which contains a
ErrorKind::InvalidInput
Review Comment:
Oh, that's not I expected. Our users should don't depend on downcast to get
the correct error kind. There are some extra work we need to:
https://github.com/apache/incubator-opendal/blob/58226a619da06f9b018955840ff976377a4a86b1/core/src/types/error.rs#L345-L355
We should mapping the opendal's error kind to io::ErrorKind correctly.
--
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]