fix: make register_bot_type idempotent (skip instead of panic on duplicate)

Prevents test panics when multiple strategies register the same bot type
in parallel test threads.
This commit is contained in:
Jan-Peter von Hunnius 2026-07-17 07:20:19 +02:00
parent e5e56fd772
commit 5a8a194be3

View file

@ -65,10 +65,11 @@ where
{
let mut map = CUSTOM_FACTORIES.write().unwrap_or_else(|e| e.into_inner());
if map.contains_key(bot_type) {
panic!(
"bot type '{}' is already registered; choose a different name",
log::debug!(
"bot type '{}' is already registered; skipping re-registration",
bot_type
);
return;
}
map.insert(bot_type.to_string(), Box::new(factory));
}