Skip to content

Commit

Permalink
add geocode suggest predefined format test
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Aug 29, 2023
1 parent 70f1e56 commit d58d5a3
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions tests/test_geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ fn geocode_suggest_dynfmt() {
svec!["East Flatbush, New York"],
svec!["Manhattan, New York"],
svec!["East Harlem, New York"],
svec!["East Harlem, New York"],
svec!["This is not a Location and it will not be geocoded"],
svec!["East Flatbush, New York"],
svec!["95.213424, 190,1234565"], // invalid lat, long
svec!["Makati, Metro Manila, Philippines"],
],
Expand All @@ -109,15 +107,50 @@ fn geocode_suggest_dynfmt() {
svec!["40.65371:-73.93042 - East Flatbush, New York"],
svec!["40.71427:-74.00597 - New York City, New York"],
svec!["40.79472:-73.9425 - East Harlem, New York"],
svec!["40.79472:-73.9425 - East Harlem, New York"],
svec!["This is not a Location and it will not be geocoded"],
svec!["40.65371:-73.93042 - East Flatbush, New York"],
svec!["95.213424, 190,1234565"], // invalid lat, long
svec!["14.55027:121.03269 - Makati City, National Capital Region"],
];
assert_eq!(got, expected);
}

#[test]
fn geocode_suggest_fmt() {
let wrk = Workdir::new("geocode_suggest_fmt");
wrk.create(
"data.csv",
vec![
svec!["Location"],
svec!["Melrose, New York"],
svec!["East Flatbush, New York"],
svec!["Manhattan, New York"],
svec!["East Harlem, New York"],
svec!["This is not a Location and it will not be geocoded"],
svec!["40.71427, -74.00597"],
svec!["Makati, Metro Manila, Philippines"],
],
);
let mut cmd = wrk.command("geocode");
cmd.arg("suggest")
.arg("Location")
.arg("--formatstr")
.arg("%city-state-country")
.arg("data.csv");

let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
let expected = vec![
svec!["Location"],
svec!["Melrose Park, Illinois, United States"],
svec!["East Flatbush, New York, United States"],
svec!["New York City, New York, United States"],
svec!["East Harlem, New York, United States"],
svec!["This is not a Location and it will not be geocoded"],
svec!["40.71427, -74.00597"], // suggest doesn't work with lat, long
svec!["Makati City, National Capital Region, Philippines"],
];
assert_eq!(got, expected);
}

#[test]
fn geocode_reverse() {
let wrk = Workdir::new("geocode_reverse");
Expand Down

0 comments on commit d58d5a3

Please sign in to comment.