crepererum commented on code in PR #676:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/676#discussion_r3046539699


##########
src/local.rs:
##########
@@ -1913,4 +1956,16 @@ mod unix_test {
 
         spawned.await.unwrap();
     }
+
+    #[test]
+    fn test_close_file_detects_error() {
+        use std::os::unix::io::AsRawFd;
+
+        let file = tempfile::tempfile().unwrap();
+        let fd = file.as_raw_fd();
+        // Close the fd behind Rust's back so close_file will get EBADF
+        assert_eq!(unsafe { libc::close(fd) }, 0);
+        let err = super::close_file(file).unwrap_err();
+        assert_eq!(err.raw_os_error(), Some(libc::EBADF));
+    }

Review Comment:
   BTW: you could also call `close_file` twice and expect that the 2nd call 
fails. That would make this test here also work on Windows.



-- 
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]

Reply via email to