diff options
Diffstat (limited to 'tests/search_crate_engine.rs')
| -rw-r--r-- | tests/search_crate_engine.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/search_crate_engine.rs b/tests/search_crate_engine.rs index 446bbf5..5273d9c 100644 --- a/tests/search_crate_engine.rs +++ b/tests/search_crate_engine.rs @@ -124,3 +124,19 @@ fn a_crate_hit_deserialises_into_the_route_hit_without_losing_keys() { // twin that could drift from it. let _: Option<SearchError> = None; } + +#[tokio::test] +async fn an_unknown_engine_name_is_refused_by_name() { + // A misconfiguration must not fall through to whichever engine sits last in + // the match, so the dispatcher has no default arm and names the value. + unsafe { std::env::set_var("SEARCH_ENGINE", "cratee") }; + let error = genenetwork4::search::search("alcohol", "phenotype", 5, 1) + .await + .expect_err("an unknown engine name is refused"); + let text = format!("{error:?}"); + assert!( + text.contains("SEARCH_ENGINE") && text.contains("cratee"), + "the refusal names the setting and the value it was given: {text}" + ); + unsafe { std::env::set_var("SEARCH_ENGINE", "crate") }; +} |
