()
| 215 | |
| 216 | #[test] |
| 217 | fn open_array_idempotent_for_same_hash() { |
| 218 | use crate::engine::array::wal::ArrayPutCell; |
| 219 | use nodedb_array::types::cell_value::value::CellValue; |
| 220 | use nodedb_array::types::coord::value::CoordValue; |
| 221 | use tempfile::TempDir; |
| 222 | |
| 223 | let dir = TempDir::new().unwrap(); |
| 224 | let mut e = ArrayEngine::new(ArrayEngineConfig::new(dir.path().to_path_buf())).unwrap(); |
| 225 | // First open registers the store and a put stamps memtable state. |
| 226 | e.open_array(aid(), schema(), 0xC0FFEE).unwrap(); |
| 227 | e.put_cells( |
| 228 | &aid(), |
| 229 | vec![ArrayPutCell { |
| 230 | coord: vec![CoordValue::Int64(4), CoordValue::Int64(4)], |
| 231 | attrs: vec![CellValue::Int64(99)], |
| 232 | surrogate: nodedb_types::Surrogate::ZERO, |
| 233 | system_from_ms: 0, |
| 234 | valid_from_ms: 0, |
| 235 | valid_until_ms: i64::MAX, |
| 236 | }], |
| 237 | 1, |
| 238 | ) |
| 239 | .unwrap(); |
| 240 | // Second open with the same hash must NOT reset state. |
| 241 | e.open_array(aid(), schema(), 0xC0FFEE).unwrap(); |
| 242 | assert_eq!( |
| 243 | e.store(&aid()).unwrap().memtable.stats().cell_count, |
| 244 | 1, |
| 245 | "idempotent re-open must preserve memtable contents" |
| 246 | ); |
| 247 | } |
| 248 | |
| 249 | #[test] |
| 250 | fn open_array_rejects_different_hash() { |
nothing calls this directly
no test coverage detected