Skip to content

Commit bbff616

Browse files
committed
expect different error
1 parent be9f602 commit bbff616

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/feature.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ mod tests {
336336
fn feature_json_invalid_geometry() {
337337
let geojson_str = r#"{"geometry":3.14,"properties":{},"type":"Feature"}"#;
338338
match geojson_str.parse::<GeoJson>().unwrap_err() {
339-
Error::FeatureInvalidGeometryValue(_) => (),
340-
_ => unreachable!(),
339+
Error::MalformedJson(e) => assert!(e.to_string().contains("expected a valid GeoJSON Geometry object")),
340+
other => panic!("expecting FeatureInvalidGeometryValue, but got: {:?}", other),
341341
}
342342
}
343343

@@ -396,18 +396,18 @@ mod tests {
396396
#[test]
397397
fn decode_feature_with_invalid_id_type_object() {
398398
let feature_json_str = "{\"geometry\":{\"coordinates\":[1.1,2.1],\"type\":\"Point\"},\"id\":{},\"properties\":{},\"type\":\"Feature\"}";
399-
assert!(matches!(
400-
feature_json_str.parse::<GeoJson>(),
401-
Err(Error::FeatureInvalidIdentifierType(_))
402-
));
399+
match feature_json_str.parse::<GeoJson>().unwrap_err() {
400+
Error::MalformedJson(e) => assert!(e.to_string().contains("Id")),
401+
other => panic!("expected different error. Got: {:?}", other),
402+
}
403403
}
404404

405405
#[test]
406406
fn decode_feature_with_invalid_id_type_null() {
407407
let feature_json_str = "{\"geometry\":{\"coordinates\":[1.1,2.1],\"type\":\"Point\"},\"id\":null,\"properties\":{},\"type\":\"Feature\"}";
408408
match feature_json_str.parse::<GeoJson>().unwrap_err() {
409-
Error::FeatureInvalidIdentifierType(_) => {} // pass,
410-
other => panic!("unexpected err: {:?}", other),
409+
Error::MalformedJson(e) => assert!(e.to_string().contains("Id")),
410+
other => panic!("expected different error. Got: {:?}", other),
411411
}
412412
}
413413

src/feature_collection.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,11 @@ mod tests {
342342

343343
let actual_failure = FeatureCollection::from_str(&geometry_json).unwrap_err();
344344
match actual_failure {
345-
Error::ExpectedType { actual, expected } => {
346-
assert_eq!(actual, "Geometry");
347-
assert_eq!(expected, "FeatureCollection");
345+
Error::MalformedJson(e) => {
346+
assert!(e.to_string().contains("missing field"));
347+
assert!(e.to_string().contains("features"));
348348
}
349-
e => panic!("unexpected error: {}", e),
350-
};
349+
other => panic!("expected other error. Got: {:?}", other)
350+
}
351351
}
352352
}

0 commit comments

Comments
 (0)