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

Function test_row_description_cache_basic

src/cache/row_description.rs:192–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

190
191 #[test]
192 fn test_row_description_cache_basic() {
193 let cache = RowDescriptionCache::new(10, Duration::from_secs(60));
194
195 let key = RowDescriptionKey {
196 query: "select * from users".to_string(),
197 table_name: Some("users".to_string()),
198 columns: vec!["id".to_string(), "name".to_string()],
199 };
200
201 let fields = vec![
202 FieldDescription {
203 name: "id".to_string(),
204 table_oid: 0,
205 column_id: 1,
206 type_oid: PgType::Int4.to_oid(),
207 type_size: 4,
208 type_modifier: -1,
209 format: 0,
210 },
211 FieldDescription {
212 name: "name".to_string(),
213 table_oid: 0,
214 column_id: 2,
215 type_oid: PgType::Text.to_oid(),
216 type_size: -1,
217 type_modifier: -1,
218 format: 0,
219 },
220 ];
221
222 // Insert and retrieve
223 cache.insert(key.clone(), fields.clone());
224 let cached = cache.get(&key).unwrap();
225 assert_eq!(cached.len(), 2);
226 assert_eq!(cached[0].name, "id");
227 assert_eq!(cached[1].name, "name");
228
229 // Check stats
230 let stats = cache.stats();
231 assert_eq!(stats.hits, 1);
232 assert_eq!(stats.misses, 0);
233 assert_eq!(stats.entries, 1);
234 }
235
236 #[test]
237 fn test_query_normalization() {

Callers

nothing calls this directly

Calls 4

insertMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected