diff options
Diffstat (limited to 'log_db/tests/integration.rs')
| -rw-r--r-- | log_db/tests/integration.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/log_db/tests/integration.rs b/log_db/tests/integration.rs index 76ed853..3e712e1 100644 --- a/log_db/tests/integration.rs +++ b/log_db/tests/integration.rs @@ -532,12 +532,13 @@ fn test_log_is_rotated_when_capacity_reached() { .with_extension("2") .exists()); + // 3rd segment should not exist (note negation) assert!(!Path::new(&data_dir) .join(ACTIVE_LOG_FILENAME) .with_extension("3") .exists()); - // Check that the active file only contains two rows + // Check that the active file only contains five rows let mut file = OpenOptions::new() .read(true) .open(Path::new(&data_dir).join(ACTIVE_LOG_FILENAME)) @@ -545,6 +546,21 @@ fn test_log_is_rotated_when_capacity_reached() { let records_in_active_log = ForwardLogReader::new(&mut file).count(); assert_eq!(records_in_active_log, 5); + // Check that each rotated file contains only 1 record + // because of compaction + for i in &[1, 2] { + let mut file = OpenOptions::new() + .read(true) + .open( + Path::new(&data_dir) + .join(ACTIVE_LOG_FILENAME) + .with_extension(i.to_string()), + ) + .expect("File could not be opened"); + let records_in_rotated_log = ForwardLogReader::new(&mut file).count(); + assert_eq!(records_in_rotated_log, 1); + } + // Look for nonexistant record to scan all segment files let found = db.get(&RecordValue::Int(2)).expect("Failed to get record"); assert!(found.is_none()); |
