add a test for invalid regex
Browse files- src/results/aggregator.rs +25 -0
src/results/aggregator.rs
CHANGED
@@ -269,4 +269,29 @@ mod tests {
|
|
269 |
|
270 |
assert!(result.is_err());
|
271 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
}
|
|
|
269 |
|
270 |
assert!(result.is_err());
|
271 |
}
|
272 |
+
|
273 |
+
#[test]
|
274 |
+
fn test_filter_with_lists_invalid_regex() {
|
275 |
+
let mut map_to_be_filtered = HashMap::new();
|
276 |
+
map_to_be_filtered.insert(
|
277 |
+
"https://www.example.com".to_string(),
|
278 |
+
SearchResult {
|
279 |
+
title: "Example Domain".to_string(),
|
280 |
+
url: "https://www.example.com".to_string(),
|
281 |
+
description: "This domain is for use in illustrative examples in documents.".to_string(),
|
282 |
+
engine: vec!["Google".to_string(), "Bing".to_string()],
|
283 |
+
},
|
284 |
+
);
|
285 |
+
|
286 |
+
let mut resultant_map = HashMap::new();
|
287 |
+
|
288 |
+
// Create a temporary file with an invalid regex pattern
|
289 |
+
let mut file = NamedTempFile::new().unwrap();
|
290 |
+
writeln!(file, "example(").unwrap();
|
291 |
+
file.flush().unwrap();
|
292 |
+
|
293 |
+
let result = filter_with_lists(&mut map_to_be_filtered, &mut resultant_map, file.path().to_str().unwrap());
|
294 |
+
|
295 |
+
assert!(result.is_err());
|
296 |
+
}
|
297 |
}
|