()
| 174 | /// `compact` drops entries older than the retention window. |
| 175 | #[test] |
| 176 | fn compact_drops_old_records() { |
| 177 | let mut analyzer = WorkloadAnalyzer::new(0.05); |
| 178 | // Timestamps: 0..50 old, 150..200 recent. |
| 179 | for i in 0u64..50 { |
| 180 | analyzer.record("old".to_string(), i); |
| 181 | } |
| 182 | for i in 150u64..200 { |
| 183 | analyzer.record("recent".to_string(), i); |
| 184 | } |
| 185 | |
| 186 | // now=200, retention=100 → cutoff=100; entries with ts < 100 removed. |
| 187 | analyzer.compact(200, 100); |
| 188 | |
| 189 | let stable = analyzer.stable_predicates(); |
| 190 | // Only "recent" entries remain. |
| 191 | assert_eq!(stable.len(), 1); |
| 192 | assert_eq!(stable[0].0, "recent"); |
| 193 | } |
| 194 | |
| 195 | /// After compacting everything, log is empty. |
| 196 | #[test] |
nothing calls this directly
no test coverage detected