fix failed test by `reserve space`
@@ -556,7 +556,6 @@ mod tests {
use std::sync::atomic::{AtomicBool, Ordering};
use std::*;
- use fs2;
use tempfile::Builder;
#[test]
@@ -726,16 +725,15 @@ mod tests {
.tempdir()
.unwrap();
let data_path = tmp_dir.path();
- let disk_stats_before = fs2::statvfs(data_path).unwrap();
- let cap1 = disk_stats_before.available_space();
- let reserve_size = 64 * 1024;
+ let file_path = data_path.join(SPACE_PLACEHOLDER_FILE);
+ let file = file_path.as_path();
+ let reserve_size = 4096 * 4;
+ assert!(!file.exists());
reserve_space_for_recover(data_path, reserve_size).unwrap();
- let disk_stats_after = fs2::statvfs(data_path).unwrap();
- let cap2 = disk_stats_after.available_space();
- assert_eq!(cap1 - cap2, reserve_size);
+ assert!(file.exists());
+ let meta = file.metadata().unwrap();
+ assert_eq!(meta.len(), reserve_size);
reserve_space_for_recover(data_path, 0).unwrap();
- let disk_stats = fs2::statvfs(data_path).unwrap();
- let cap3 = disk_stats.available_space();
- assert_eq!(cap1, cap3);
+ assert!(!file.exists());
}
}
