use std::sync::Arc;
use rypsok_core::limits::Limits;
use rypsok_core::model::CallerId;
use super::CallerLimiters;
#[test]
fn req_sec_014_poisoned_caller_lock_does_not_stop_the_limiters() {
let limiters = Arc::new(CallerLimiters::new(&Limits::default()));
let before = limiters.for_caller(&CallerId::local());
let shared = Arc::clone(&limiters);
let outcome = std::thread::spawn(move || {
let _guard = shared.callers.lock().unwrap();
panic!("poisoning the lock on purpose");
})
.join();
assert!(outcome.is_err());
assert!(limiters.callers.is_poisoned());
let after = limiters.for_caller(&CallerId::local());
assert!(Arc::ptr_eq(&before, &after));
let other = limiters.for_caller(&CallerId::new("mimlys"));
assert!(other.search.admit().is_ok());
}
#[test]
fn req_mcp_010_a_limiter_debug_names_the_type_only() {
assert_eq!(
format!("{:?}", super::ToolLimiter::per_minute(5)),
"ToolLimiter"
);
}