MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_pressure_level_calculation

Function test_pressure_level_calculation

src/protocol/memory_monitor.rs:474–501  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

472
473 #[test]
474 fn test_pressure_level_calculation() {
475 let config = MemoryMonitorConfig {
476 memory_threshold: 1000,
477 high_memory_threshold: 2000,
478 ..Default::default()
479 };
480 let monitor = MemoryMonitor::with_config(config);
481
482 // Test low pressure
483 monitor.record_buffer_allocation(500);
484 monitor.check_memory_pressure();
485 assert_eq!(monitor.get_stats().pressure_level, MemoryPressure::Low);
486
487 // Test medium pressure
488 monitor.record_buffer_allocation(600); // Total: 1100
489 monitor.check_memory_pressure();
490 assert_eq!(monitor.get_stats().pressure_level, MemoryPressure::Medium);
491
492 // Test high pressure
493 monitor.record_buffer_allocation(1000); // Total: 2100
494 monitor.check_memory_pressure();
495 assert_eq!(monitor.get_stats().pressure_level, MemoryPressure::High);
496
497 // Test critical pressure
498 monitor.record_buffer_allocation(2000); // Total: 4100
499 monitor.check_memory_pressure();
500 assert_eq!(monitor.get_stats().pressure_level, MemoryPressure::Critical);
501 }
502
503 #[test]
504 fn test_cleanup_callbacks() {

Callers

nothing calls this directly

Calls 2

check_memory_pressureMethod · 0.45

Tested by

no test coverage detected