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

Function test_cache_eviction

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

Source from the content-addressed store, hash-verified

422
423#[test]
424fn 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

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