dqhl76 commented on code in PR #2644: URL: https://github.com/apache/incubator-opendal/pull/2644#discussion_r1263578549
########## 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: I found that `let res = r.seek(std::io::SeekFrom::Current(-1024)).await;` will return a std error `Interrupted` not `InvalidInput`. It seems not a good idea to map them together. https://github.com/apache/incubator-opendal/blob/58226a619da06f9b018955840ff976377a4a86b1/core/src/raw/oio/read.rs#L172 I am not sure how to do that here --- ```rs let res = r.seek(std::io::SeekFrom::Current(-1024)).await; assert!(res.is_err()); let err = res.unwrap_err().kind(); debug!("{}",err); ``` ``` 2023-07-14T12:20:38.665904Z DEBUG behavior::write: operation interrupted at core/tests/behavior/write.rs:1253 ``` -- 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: commits-unsubscr...@opendal.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org