| 1 | use super::*; |
| 2 | use std::io::{Error, ErrorKind}; |
| 3 | |
| 4 | #[test] |
| 5 | fn storage_full_is_distinct_from_other_io_errors() { |
| 6 | assert_eq!(io_error(ErrorKind::StorageFull.into()), ErrorCode::DiskFull); |
| 7 | assert_eq!( |
| 8 | io_error(ErrorKind::QuotaExceeded.into()), |
| 9 | ErrorCode::DiskFull |
| 10 | ); |
| 11 | for kind in [ |
| 12 | ErrorKind::PermissionDenied, |
| 13 | ErrorKind::Other, |
| 14 | ErrorKind::NotFound, |
| 15 | ] { |
| 16 | assert_eq!(io_error(kind.into()), ErrorCode::Io); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | #[cfg(target_os = "linux")] |
| 21 | #[test] |
| 22 | fn native_linux_enospc_is_disk_full() { |
| 23 | assert_eq!(io_error(Error::from_raw_os_error(28)), ErrorCode::DiskFull); |
| 24 | // EDQUOT: tmpfs usrquota 등 사용자 할당량 초과도 권한 오류로 안내하지 않음. |
| 25 | assert_eq!(io_error(Error::from_raw_os_error(122)), ErrorCode::DiskFull); |
| 26 | for code in [5, 13, 39, 112] { |
| 27 | assert_eq!(io_error(Error::from_raw_os_error(code)), ErrorCode::Io); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | #[cfg(windows)] |
| 32 | #[test] |
| 33 | fn native_windows_disk_full_codes_are_distinct_from_access_denied() { |
| 34 | for code in [39, 112, 1295] { |
| 35 | assert_eq!( |
| 36 | io_error(Error::from_raw_os_error(code)), |
| 37 | ErrorCode::DiskFull |
| 38 | ); |
| 39 | } |
| 40 | assert_eq!(io_error(Error::from_raw_os_error(5)), ErrorCode::Io); |
| 41 | } |