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

Function test_connection_timeout_and_cleanup

src/session/pool.rs:408–428  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

406
407 #[tokio::test]
408 async fn test_connection_timeout_and_cleanup() {
409 // Test with very short timeout for faster test
410 let pool = SqlitePool::new_with_config(
411 ":memory:",
412 2,
413 Duration::from_millis(100), // Very short idle timeout
414 Duration::from_millis(50), // Very short health check interval
415 ).unwrap();
416
417 let conn = pool.acquire().await.unwrap();
418 drop(conn); // Return to pool
419
420 // Wait for background cleanup
421 sleep(Duration::from_millis(200)).await;
422
423 // The background task should have run and potentially cleaned up idle connections
424 // (exact behavior depends on timing, but this tests that the mechanism works)
425 let _stats = pool.get_stats();
426 // The background task should have run and health checks should have occurred
427 // No specific assertion needed since health_checks_performed is always >= 0
428 }
429}

Callers

nothing calls this directly

Calls 2

acquireMethod · 0.80
get_statsMethod · 0.45

Tested by

no test coverage detected