use std::{cell::Cell, io};
#[test]
fn file_probe_returns_success_and_permanent_errors_without_backoff() {
let calls = Cell::new(0);
let result = super::retry_transient_access(
|| {
calls.set(calls.get() + 1);
Ok(7)
},
|| panic!("successful probes need no backoff"),
);
assert_eq!(result.unwrap(), 7);
assert_eq!(calls.get(), 1);
let calls = Cell::new(0);
let result = super::retry_transient_access(
|| {
calls.set(calls.get() + 1);
Err::<(), _>(io::Error::other("permanent probe failure"))
},
|| panic!("permanent errors cannot be retried"),
);
assert_eq!(result.unwrap_err().to_string(), "permanent probe failure");
assert_eq!(calls.get(), 1);
}