summaryrefslogtreecommitdiff
path: root/jstests/core/timeseries
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/timeseries')
-rw-r--r--jstests/core/timeseries/timeseries_metric_index_2dsphere.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/jstests/core/timeseries/timeseries_metric_index_2dsphere.js b/jstests/core/timeseries/timeseries_metric_index_2dsphere.js
index 5997a8254e3..a7fece34c53 100644
--- a/jstests/core/timeseries/timeseries_metric_index_2dsphere.js
+++ b/jstests/core/timeseries/timeseries_metric_index_2dsphere.js
@@ -92,12 +92,15 @@ TimeseriesTest.run((insert) => {
assert.commandWorked(insert(timeseriescoll, twoDSphereDocs),
'Failed to insert twoDSphereDocs: ' + tojson(twoDSphereDocs));
- const invalidDocs = [
- {
- _id: 6,
- [timeFieldName]: ISODate(),
- location: {type: "Polygon", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]}
- },
+ // Test invalid documents
+ const docWithInvalidCoordinates = {
+ _id: 6,
+ [timeFieldName]: ISODate(),
+ location: {type: "Polygon", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]}
+ };
+ // Can't extract geo keys: GeoJSON coordinates must be an array
+ assert.commandFailedWithCode(insert(timeseriescoll, docWithInvalidCoordinates), 183934);
+ const docsWithTypeNotPoint = [
{
_id: 7,
[timeFieldName]: ISODate(),
@@ -109,10 +112,10 @@ TimeseriesTest.run((insert) => {
location: {type: "LineString", coordinates: [[0, 0], [1, 0], [1, 1], [0, 0]]}
}
];
- for (const invalidDoc in invalidDocs) {
- assert.commandFailedWithCode(assert.throws(() => insert(timeseriescoll, invalidDoc)),
- ErrorCodes.BadValue);
- }
+ docsWithTypeNotPoint.forEach((invalidDoc) => {
+ // Time-series collections '2dsphere' indexes only support point data
+ assert.commandFailedWithCode(insert(timeseriescoll, invalidDoc), 183493);
+ });
// Assert that geoWithin queries use the index.
const geoWithinPlan =