()
| 198 | |
| 199 | #[test] |
| 200 | fn test_content_cache_reuses_reads() { |
| 201 | let temp = TempDir::new().unwrap(); |
| 202 | let project_root = temp.path(); |
| 203 | |
| 204 | fs::write( |
| 205 | project_root.join("package.json"), |
| 206 | r#"{"dependencies": {"react": "^18.0.0"}}"#, |
| 207 | ) |
| 208 | .unwrap(); |
| 209 | |
| 210 | let detector = catalog_detector(); |
| 211 | let mut cache = ContentCache::new(); |
| 212 | |
| 213 | // First detection |
| 214 | let detections1 = detector.detect(project_root, &mut cache).unwrap(); |
| 215 | |
| 216 | // Cache should now contain package.json |
| 217 | assert!(!cache.is_empty(), "Cache should contain read files"); |
| 218 | |
| 219 | // Second detection should reuse cache |
| 220 | let detections2 = detector.detect(project_root, &mut cache).unwrap(); |
| 221 | |
| 222 | assert_eq!( |
| 223 | detections1.len(), |
| 224 | detections2.len(), |
| 225 | "Should get same results from cache" |
| 226 | ); |
| 227 | } |
| 228 | |
| 229 | #[test] |
| 230 | fn test_detect_with_empty_project() { |
nothing calls this directly
no test coverage detected