()
| 422 | |
| 423 | #[test] |
| 424 | fn test_cache_eviction() { |
| 425 | // Create store with small cache |
| 426 | let temp_dir = create_temp_dir(); |
| 427 | let changes_dir = temp_dir.path().join("changes"); |
| 428 | let store = ChangeStore::new(changes_dir, 2).expect("Failed to create store"); |
| 429 | |
| 430 | // Save 3 changes (more than cache capacity) |
| 431 | let mut hashes = Vec::new(); |
| 432 | for i in 0..3 { |
| 433 | let change = create_test_change(&format!("Change {}", i)); |
| 434 | let hash = store.save_change(&change).expect("Failed to save change"); |
| 435 | hashes.push(hash); |
| 436 | } |
| 437 | |
| 438 | // Cache should have at most 2 entries |
| 439 | assert!(store.cache_size() <= 2); |
| 440 | |
| 441 | // All changes should still be loadable from disk |
| 442 | for hash in &hashes { |
| 443 | store.clear_cache(); |
| 444 | let result = store.load_change(hash); |
| 445 | assert!( |
| 446 | result.is_ok(), |
| 447 | "Should load change {} from disk", |
| 448 | hash.to_base32() |
| 449 | ); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | // Error Condition Tests |
| 454 |
nothing calls this directly
no test coverage detected