use std::sync::{Mutex, MutexGuard, OnceLock};
pub struct TestPlugin {
pub value: u32,
}
impl crate::plugin::SampPlugin for TestPlugin {}
pub fn exclusive() -> MutexGuard<'static, ()> {
static LOCK: Mutex<()> = Mutex::new(());
static INSTALLED: OnceLock<()> = OnceLock::new();
let guard = LOCK.lock().unwrap_or_else(|e| e.into_inner());
INSTALLED.get_or_init(|| {
let rt = crate::runtime::Runtime::initialize();
rt.set_plugin(TestPlugin { value: 0 });
});
guard
}
pub fn value() -> u32 {
crate::plugin::with_instance::<TestPlugin, _>(|p| p.value)
.expect("the fixture installs the plugin before any test body runs")
}