Skip to content

Commit

Permalink
fix(fs-storage): add delay in tests after file write
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Jun 12, 2024
1 parent 3831efc commit fedfdf1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs-storage/src/file_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,15 @@ mod tests {
let mut file_storage =
FileStorage::new("TestStorage".to_string(), &storage_path).unwrap();
file_storage.write_fs().unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));

file_storage.set("key1".to_string(), "value1".to_string());
let before_write = fs::metadata(&storage_path)
.unwrap()
.modified()
.unwrap();
file_storage.write_fs().unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));
let after_write = fs::metadata(&storage_path)
.unwrap()
.modified()
Expand All @@ -395,6 +397,7 @@ mod tests {
let mut file_storage =
FileStorage::new("TestStorage".to_string(), &storage_path).unwrap();
file_storage.write_fs().unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));
assert_eq!(file_storage.sync_status().unwrap(), SyncStatus::InSync);

file_storage.set("key1".to_string(), "value1".to_string());
Expand All @@ -403,6 +406,7 @@ mod tests {
SyncStatus::StorageStale
);
file_storage.write_fs().unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));
assert_eq!(file_storage.sync_status().unwrap(), SyncStatus::InSync);

// External data manipulation
Expand All @@ -418,6 +422,7 @@ mod tests {
);

mirror_storage.write_fs().unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));
assert_eq!(mirror_storage.sync_status().unwrap(), SyncStatus::InSync);

// receive updates from external data manipulation
Expand Down

0 comments on commit fedfdf1

Please sign in to comment.