diff options
| author | Alexander_Kabui <alexanderkabui@proton.me> | 2026-11-17 12:11:19 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabui@proton.me> | 2026-11-17 14:06:50 +0300 |
| commit | f76043bf82b6c86b5e844b27b53e957d770aeb33 (patch) | |
| tree | 5b4257c2523410f077e9fbc4f71f3fd797360b9f /tests/search_crate_engine.rs | |
| parent | e13bbd27d0b7addd277d0f50d9e90fee2a936211 (diff) | |
| download | genenetwork4-search/extract-engine.tar.gz | |
* src/search (engine): no default arm, so a wrong name is refused. search/extract-engine
An unrecognised SEARCH_ENGINE used to fall through to the gn3 proxy, which turned a typo into a silently different engine. The arms are now explicit - "crate"/"native" for the in-process engine, "forward" for the proxy - and anything else returns the value it was given. src/search/native.rs is deleted; the former name resolves through the same arm.
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") }; +} |
