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:
parent
e5e56fd772
commit
5a8a194be3
1 changed files with 3 additions and 2 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue