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

Function test_lazy_schema_loading

src/cache/lazy_schema_loader.rs:298–320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 3

get_schemaMethod · 0.80
executeMethod · 0.45
get_statsMethod · 0.45

Tested by

no test coverage detected