From 9a319aed1201be96503fcc8e8f13c1e95b84de20 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:24:48 -0400 Subject: [PATCH] `geocode`: add non-trivial tests for suggestnow and reversenow subcommands --- tests/test_geocode.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test_geocode.rs b/tests/test_geocode.rs index a4aa5a44f..ad8981d8e 100644 --- a/tests/test_geocode.rs +++ b/tests/test_geocode.rs @@ -141,6 +141,42 @@ fn geocode_suggest_intl_admin1_filter_error() { wrk.assert_err(&mut cmd); } +#[test] +fn geocode_suggestnow() { + let wrk = Workdir::new("geocode_suggestnow"); + + let mut cmd = wrk.command("geocode"); + cmd.arg("suggestnow") + .arg("Paris") + .args(["--country", "US"]) + .args(["-f", "%city-admin1-country"]); + + let got: Vec> = wrk.read_stdout(&mut cmd); + let expected = vec![svec!["location"], svec!["Paris, Texas United States"]]; + assert_eq!(got, expected); +} + +#[test] +fn geocode_reversenow() { + let wrk = Workdir::new("geocode_reversenow"); + + let mut cmd = wrk.command("geocode"); + cmd.arg("reversenow") + .arg("(40.67, -73.94)") + .args(["--admin1", "New York"]) + .args([ + "-f", + "{name}, {admin2} County, {admin1} - {population} {timezone}", + ]); + + let got: Vec> = wrk.read_stdout(&mut cmd); + let expected = vec![ + svec!["location"], + svec!["East Flatbush, Kings County, New York - 178464 America/New_York"], + ]; + assert_eq!(got, expected); +} + #[test] fn geocode_suggest_intl_admin1_filter_country_inferencing() { let wrk = Workdir::new("geocode_suggest_intl_admin1_filter_country_inferencing");