diff --git a/crates/engine/src/cmd/geocode.rs b/crates/engine/src/cmd/geocode.rs index c9ffb6b7e..feb9b033e 100644 --- a/crates/engine/src/cmd/geocode.rs +++ b/crates/engine/src/cmd/geocode.rs @@ -63,6 +63,13 @@ impl PlaceNames { self.lock().running } + /// Whether a place names download has been started in this session (running, or ended). + #[cfg(test)] + pub(crate) fn download_started(&self) -> bool { + let sh = self.lock(); + sh.running || sh.last.is_some() + } + /// The gazetteer in `dir`, parsed once and re-read only when the cities file's size or time changes. fn load(&mut self, dir: &Path) -> std::result::Result, lightcraft_geocode::GeocodeError> { let file = dir.join(GEONAMES_FILES[0]); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 1e8f4b7e3..5a1d705ba 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -452,8 +452,14 @@ fn command_sweep() { for c in command_specs() { assert!(ids.insert(c.id), "duplicate {}", c.id); assert!(!c.label.is_empty() && !c.params.is_empty(), "{}", c.id); + // empty params make this one download from download.geonames.org into the real settings folder; its own tests run it against a loopback server + if c.id == "metadata.downloadPlaceNames" { + continue; + } let _ = s.execute(c.id, &Value::Null); } + // empty params must never start a download from the internet + assert!(!s.place_names.download_started(), "the sweep started a place names download"); assert!(s.commands().len() >= 70, "{}", s.commands().len()); }