Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(voice): add factory and registry test modules

Steven Enamakel3f17797a40dc
diff --git a/crates/openhuman-core/src/voice/factory/factory_tests.rs b/crates/openhuman-core/src/voice/factory/factory_tests.rs
index b5ac66dd4c..d71d226026 100644
--- a/crates/openhuman-core/src/voice/factory/factory_tests.rs
+++ b/crates/openhuman-core/src/voice/factory/factory_tests.rs
@@ -1,8 +1,7 @@
//! Unit tests for the voice factory.
use super::entry::{
- create_stt_provider, create_tts_provider, default_stt_provider, default_tts_provider,
- resolve_tts_voice, DEFAULT_PIPER_VOICE,
+ create_stt_provider, create_tts_provider, resolve_tts_voice, DEFAULT_PIPER_VOICE,
};
use super::helpers::{effective_stt_provider, effective_tts_provider, split_slug_model};
use crate::config::schema::voice_providers::VoiceCapability;
@@ -14,18 +13,6 @@ fn cfg() -> Config {
Config::default()
}
-#[test]
-fn stt_factory_cloud_branch() {
- let p = create_stt_provider("cloud", "ignored", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
-}
-
-#[test]
-fn stt_factory_backend_alias() {
- let p = create_stt_provider("backend", "ignored", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
-}
-
/// The bundled whisper.cpp engine is gone, so `"whisper"` is no longer a
/// sentinel: it falls through to the slug lookup and errors by name. A silent
/// remap to cloud would hide an unmigrated config instead of surfacing it.
@@ -44,12 +31,6 @@ fn stt_factory_removed_local_engine_errors_rather_than_falling_back() {
}
}
-#[test]
-fn stt_factory_openhuman_sentinel() {
- let p = create_stt_provider("openhuman", "ignored", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
-}
-
#[test]
fn stt_factory_slug_without_registry_errors() {
let err = create_stt_provider("deepgram", "nova-2", &cfg())
@@ -121,12 +102,6 @@ fn stt_factory_empty_string_errors() {
assert!(err.to_string().contains("no voice provider"));
}
-#[test]
-fn tts_factory_cloud_branch() {
- let p = create_tts_provider("cloud", "Rachel", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
-}
-
#[test]
fn tts_factory_piper_branch() {
let p = create_tts_provider("piper", "en_US-lessac-medium", &cfg()).unwrap();
@@ -251,28 +226,6 @@ fn tts_factory_slug_empty_voice_uses_registry_default() {
);
}
-#[test]
-fn tts_factory_cloud_empty_voice_carries_no_voice() {
- // The #5355 regression, asserted end-to-end through the boxed provider:
- // nothing but `None` may reach `CloudTtsProvider`, or `synthesize_reply`
- // puts a Piper id in `voice_id` and the backend answers 400.
- for provider in ["cloud", "openhuman"] {
- let p = create_tts_provider(provider, "", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
- assert_eq!(
- p.configured_voice(),
- None,
- "{provider} must carry no voice so the backend default applies"
- );
- }
-}
-
-#[test]
-fn tts_factory_cloud_preserves_explicit_voice() {
- let p = create_tts_provider("cloud", "JBFqnCBsd6RMkjVDRZzb", &cfg()).unwrap();
- assert_eq!(p.configured_voice(), Some("JBFqnCBsd6RMkjVDRZzb"));
-}
-
#[test]
fn tts_factory_piper_empty_voice_carries_bundled_voice() {
// The other half of the guarantee: Piper — and only Piper — still gets the
@@ -299,12 +252,6 @@ fn tts_factory_slug_colon_voice_reaches_provider() {
assert_eq!(p.configured_voice(), Some("shimmer"));
}
-#[test]
-fn tts_factory_openhuman_sentinel() {
- let p = create_tts_provider("openhuman", "alloy", &cfg()).unwrap();
- assert_eq!(p.name(), "cloud");
-}
-
#[test]
fn tts_factory_slug_without_registry_errors() {
let err = create_tts_provider("kokoro", "af_bella", &cfg())
@@ -351,12 +298,6 @@ fn tts_factory_stt_only_provider_rejects() {
assert!(err.to_string().contains("does not support TTS"));
}
-#[test]
-fn default_providers_return_cloud() {
- assert_eq!(default_stt_provider().name(), "cloud");
- assert_eq!(default_tts_provider().name(), "cloud");
-}
-
// ── slug:model parsing ──────────────────────────────────────────────
#[test]
@@ -458,3 +399,25 @@ fn effective_tts_defaults_to_cloud() {
let config = cfg();
assert_eq!(effective_tts_provider(&config), "cloud");
}
+
+/// The core carries no hosted provider: `cloud`, `openhuman` and `backend` are
+/// slugs the hosted-backend layer registers, so with nothing registered they
+/// error by name instead of resolving to a built-in.
+#[test]
+fn hosted_slugs_error_by_name_when_nothing_is_registered() {
+ for slug in ["cloud", "openhuman", "backend"] {
+ let err = create_stt_provider(slug, "", &cfg())
+ .err()
+ .unwrap_or_else(|| panic!("stt `{slug}` must not resolve without a registration"))
+ .to_string();
+ assert!(err.contains(slug), "{err}");
+ assert!(err.contains("no voice provider"), "{err}");
+ }
+ for slug in ["cloud", "openhuman"] {
+ let err = create_tts_provider(slug, "", &cfg())
+ .err()
+ .unwrap_or_else(|| panic!("tts `{slug}` must not resolve without a registration"))
+ .to_string();
+ assert!(err.contains(slug), "{err}");
+ }
+}
diff --git a/crates/openhuman-core/src/voice/factory/registry_tests.rs b/crates/openhuman-core/src/voice/factory/registry_tests.rs
index f8ea5800b1..da3d156857 100644
--- a/crates/openhuman-core/src/voice/factory/registry_tests.rs
+++ b/crates/openhuman-core/src/voice/factory/registry_tests.rs
@@ -93,7 +93,7 @@ async fn a_registered_stt_slug_is_built_with_the_effective_model() {
}
#[test]
-fn a_registered_slug_replaces_the_hard_coded_cloud_route() {
+fn a_registered_slug_answers_under_the_hosted_slug() {
register_stt_provider("cloud", |_, _| {
Ok(Box::new(FakeStt {
model: String::new(),
@@ -102,9 +102,8 @@ fn a_registered_slug_replaces_the_hard_coded_cloud_route() {
let provider = create_stt_provider("cloud", "", &Config::default()).unwrap();
unregister_stt_provider("cloud");
assert_eq!(provider.name(), "fake-stt");
- // With the registration gone the built-in cloud provider answers again.
- let builtin = create_stt_provider("cloud", "", &Config::default()).unwrap();
- assert_ne!(builtin.name(), "fake-stt");
+ // With the registration gone the core has no `cloud` provider of its own.
+ assert!(create_stt_provider("cloud", "", &Config::default()).is_err());
}
#[tokio::test]