in src/geoip.rs [124:147]
fn test_geoip_sends_metrics() -> Result<(), Box<dyn std::error::Error>> {
let log = Arc::new(Mutex::new(Vec::new()));
let metrics = Arc::new(StatsdClient::from_sink(
"test",
TestMetricSink { log: log.clone() },
));
let geoip = super::GeoIp::builder()
.path("./GeoLite2-Country.mmdb")
.metrics(metrics)
.build()?;
geoip.locate("7.7.7.7".parse()?)?;
geoip.locate("127.0.0.1".parse()?)?;
assert_eq!(
*log.lock().unwrap().deref(),
vec![
"test.location:1|c|#country:US",
"test.location:1|c|#country:unknown",
]
);
Ok(())
}