mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Add test for bug #3007: Wrong error message
Adds a test for #3007: Wrong error message when lat and lng are unparseable
This commit is contained in:
parent
63af1e9f28
commit
497187083b
@ -2292,4 +2292,40 @@ pub(crate) mod tests {
|
||||
assert!(all_ids.insert(id));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bug_3007() {
|
||||
// https://github.com/meilisearch/meilisearch/issues/3007
|
||||
|
||||
use crate::error::{GeoError, UserError};
|
||||
let index = TempIndex::new();
|
||||
|
||||
// Given is an index with a geo field NOT contained in the sortable_fields of the settings
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
settings.set_primary_key("id".to_string());
|
||||
settings.set_filterable_fields(HashSet::from(["_geo".to_string()]));
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// happy path
|
||||
index.add_documents(documents!({ "id" : 5, "_geo": {"lat": 12.0, "lng": 11.0}})).unwrap();
|
||||
|
||||
db_snap!(index, geo_faceted_documents_ids);
|
||||
|
||||
// both are unparseable, we expect GeoError::BadLatitudeAndLongitude
|
||||
let err1 = index
|
||||
.add_documents(
|
||||
documents!({ "id" : 6, "_geo": {"lat": "unparseable", "lng": "unparseable"}}),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(matches!(
|
||||
err1,
|
||||
Error::UserError(UserError::InvalidGeoField(
|
||||
GeoError::BadLatitudeAndLongitude { .. }
|
||||
))
|
||||
));
|
||||
|
||||
db_snap!(index, geo_faceted_documents_ids); // ensure that no more document was inserted
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
source: milli/src/index.rs
|
||||
---
|
||||
[0, ]
|
Loading…
Reference in New Issue
Block a user