()
| 296 | |
| 297 | #[test] |
| 298 | fn test_lazy_schema_loading() { |
| 299 | let conn = Connection::open_in_memory().unwrap(); |
| 300 | |
| 301 | // Create a test table |
| 302 | conn.execute("CREATE TABLE test_table (id INTEGER, name TEXT)", []).unwrap(); |
| 303 | |
| 304 | let loader = LazySchemaLoader::new(300); |
| 305 | |
| 306 | // First access should load from database |
| 307 | let schema1 = loader.get_schema(&conn, "test_table").unwrap().unwrap(); |
| 308 | assert_eq!(schema1.columns.len(), 2); |
| 309 | |
| 310 | // Second access should hit cache |
| 311 | let schema2 = loader.get_schema(&conn, "test_table").unwrap().unwrap(); |
| 312 | assert_eq!(schema1.columns.len(), schema2.columns.len()); |
| 313 | |
| 314 | // Check statistics |
| 315 | let stats = loader.get_stats(); |
| 316 | assert_eq!(stats.cache_hits, 1); |
| 317 | assert_eq!(stats.cache_misses, 1); |
| 318 | assert_eq!(stats.schemas_loaded, 1); |
| 319 | assert!(loader.get_cache_hit_rate() > 0.0); |
| 320 | } |
| 321 | |
| 322 | #[test] |
| 323 | fn test_nonexistent_table() { |
nothing calls this directly
no test coverage detected