MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_cache_eviction

Function test_cache_eviction

atomic-repository/src/changestore/tests.rs:490–517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

488
489#[test]
490fn 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

Callers

nothing calls this directly

Calls 7

create_temp_dirFunction · 0.85
clear_cacheMethod · 0.80
create_test_changeFunction · 0.70
pathMethod · 0.45
save_changeMethod · 0.45
pushMethod · 0.45
load_changeMethod · 0.45

Tested by

no test coverage detected