diff --git a/src/lib.rs b/src/lib.rs index c9b6ecd..a0ebf04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1054,6 +1054,25 @@ mod tests { Ok(()) } + #[test] + fn search_config_builder_methods_populate_fields() { + let config = SearchConfig::new("https://example.com") + .unwrap() + .with_blocklist(["badsite.com", "spam.org"]) + .with_allowlist(["goodsite.com"]) + .with_timeout(std::time::Duration::from_secs(10)) + .with_cache(100, std::time::Duration::from_secs(300)); + + assert_eq!( + config.blocklist, + vec!["badsite.com".to_owned(), "spam.org".to_owned()] + ); + assert_eq!(config.allowlist, vec!["goodsite.com".to_owned()]); + assert_eq!(config.timeout, std::time::Duration::from_secs(10)); + assert_eq!(config.cache_capacity, 100); + assert_eq!(config.cache_ttl, std::time::Duration::from_secs(300)); + } + #[test] fn search_config_from_url_validates_scheme_and_credentials() -> Result<(), url::ParseError> { // Valid URLs @@ -1333,7 +1352,10 @@ mod tests { filters: SearchFilters::default(), }; - client.cache.insert("rust".to_owned(), dummy_response); + client.cache.insert( + (false, SearchMode::Balanced, "rust".to_owned()), + dummy_response, + ); assert_eq!(client.cached_entries(), 1); client.clear_cache();