mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-01-31 07:55:23 +00:00
Reset registered regions on setup call.
This ensures that each test will reset the regions hashmap.
This commit is contained in:
parent
e78dac316a
commit
02d66b8a5d
@ -742,7 +742,7 @@ pub fn get_region_network(region_id: &str) -> Result<RegionNetwork> {
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!("region_id not found"))
|
||||
Err(anyhow!("Region ID '{}' not found", region_id))
|
||||
}
|
||||
|
||||
pub fn get_region_gateway(region_id: &str) -> Result<RegionGateway> {
|
||||
@ -753,7 +753,7 @@ pub fn get_region_gateway(region_id: &str) -> Result<RegionGateway> {
|
||||
}
|
||||
}
|
||||
|
||||
Err(anyhow!("region_id not found"))
|
||||
Err(anyhow!("Region ID '{}' not found", region_id))
|
||||
}
|
||||
|
||||
pub fn get_required_snr_for_sf(sf: u8) -> Result<f32> {
|
||||
|
@ -16,6 +16,8 @@ pub fn setup() -> Result<()> {
|
||||
info!("Setting up regions");
|
||||
let conf = config::get();
|
||||
|
||||
reset();
|
||||
|
||||
for r in &conf.regions {
|
||||
let span = span!(Level::INFO, "setup", common_name = %r.common_name, region_id = %r.id);
|
||||
let _guard = span.enter();
|
||||
@ -63,6 +65,11 @@ pub fn setup() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn reset() {
|
||||
let mut regions_w = REGIONS.write().unwrap();
|
||||
regions_w.clear();
|
||||
}
|
||||
|
||||
pub fn set(region_config_id: &str, r: Box<dyn region::Region + Sync + Send>) {
|
||||
let mut regions_w = REGIONS.write().unwrap();
|
||||
regions_w.insert(region_config_id.to_string(), Arc::new(r));
|
||||
|
Loading…
x
Reference in New Issue
Block a user