()
| 488 | |
| 489 | #[test] |
| 490 | fn test_cache_eviction() { |
| 491 | // Create store with small cache |
| 492 | let temp_dir = create_temp_dir(); |
| 493 | let changes_dir = temp_dir.path().join("changes"); |
| 494 | let store = ChangeStore::new(changes_dir, 2).expect("Failed to create store"); |
| 495 | |
| 496 | // Save 3 changes (more than cache capacity) |
| 497 | let mut hashes = Vec::new(); |
| 498 | for i in 0..3 { |
| 499 | let change = create_test_change(&format!("Change {}", i)); |
| 500 | let hash = store.save_change(&change).expect("Failed to save change"); |
| 501 | hashes.push(hash); |
| 502 | } |
| 503 | |
| 504 | // Cache should have at most 2 entries |
| 505 | assert!(store.cache_size() <= 2); |
| 506 | |
| 507 | // All changes should still be loadable from disk |
| 508 | for hash in &hashes { |
| 509 | store.clear_cache(); |
| 510 | let result = store.load_change(hash); |
| 511 | assert!( |
| 512 | result.is_ok(), |
| 513 | "Should load change {} from disk", |
| 514 | hash.to_base32() |
| 515 | ); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | // Error Condition Tests |
| 520 |
nothing calls this directly
no test coverage detected